mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
c68c4c804d
Fix Issue https://github.com/Unidata/netcdf-c/issues/1725. Replace PR https://github.com/Unidata/netcdf-c/pull/1726 Also replace PR https://github.com/Unidata/netcdf-c/pull/1694 The general problem is that under Visual Studio, we are seeing a number of undefined reference and other scoping errors. The reason is that the code is not properly using Visual Studio _declspec() declarations. The basic solution is to ensure that when compiling the code itself one needs to ensure that _declspec(dllexport) is used. There are several sets of macros to handle this, but they all rely on the flag DLL_EXPORT being define when the code is compiled, but not being defined when the code is used via a .h file. As a test, I modified XGetOpt.c to build properly. I also fixed the oc2 library to properly _declspec things like ocdebug. I also made some misc. changes to get all the tests to run if cygwin is installed (to get bash, sed, etc). Misc. Changes: * Put XGetOpt.c into libsrc and copy at build time to the other directories where it is needed.
81 lines
1.5 KiB
C
81 lines
1.5 KiB
C
/* Copyright 2018, UCAR/Unidata and OPeNDAP, Inc.
|
|
See the COPYRIGHT file for more information. */
|
|
|
|
#include "config.h"
|
|
#ifdef HAVE_STDARG_H
|
|
#include <stdarg.h>
|
|
#endif
|
|
#include "ocinternal.h"
|
|
#include "ocdebug.h"
|
|
|
|
#ifdef OCCATCHERROR
|
|
/* Place breakpoint here to catch errors close to where they occur*/
|
|
OCerror
|
|
ocbreakpoint(OCerror err) {return err;}
|
|
|
|
OCerror
|
|
occatch(OCerror err)
|
|
{
|
|
if(err == 0) return err;
|
|
return ocbreakpoint(err);
|
|
}
|
|
#endif
|
|
|
|
int
|
|
xxdrerror(void)
|
|
{
|
|
nclog(NCLOGERR,"xdr failure");
|
|
return OCCATCH(OC_EDATADDS);
|
|
}
|
|
|
|
|
|
void*
|
|
occalloc(size_t size, size_t nelems)
|
|
{
|
|
return ocmalloc(size*nelems);
|
|
}
|
|
|
|
void*
|
|
ocmalloc(size_t size)
|
|
{
|
|
void* memory = calloc(size,1); /* use calloc to zero memory*/
|
|
if(memory == NULL) nclog(NCLOGERR,"ocmalloc: out of memory");
|
|
return memory;
|
|
}
|
|
|
|
void
|
|
ocfree(void* mem)
|
|
{
|
|
if(mem != NULL) free(mem);
|
|
}
|
|
|
|
int
|
|
ocpanic(const char* fmt, ...)
|
|
{
|
|
va_list args;
|
|
if(fmt != NULL) {
|
|
va_start(args, fmt);
|
|
vfprintf(stderr, fmt, args);
|
|
fprintf(stderr, "\n" );
|
|
va_end( args );
|
|
} else {
|
|
fprintf(stderr, "panic" );
|
|
}
|
|
fprintf(stderr, "\n" );
|
|
fflush(stderr);
|
|
return 0;
|
|
}
|
|
|
|
CURLcode
|
|
ocreportcurlerror(OCstate* state, CURLcode cstat)
|
|
{
|
|
if(cstat != CURLE_OK) {
|
|
fprintf(stderr,"CURL Error: %s",curl_easy_strerror(cstat));
|
|
if(state != NULL)
|
|
fprintf(stderr," ; %s",state->error.curlerrorbuf);
|
|
fprintf(stderr,"\n");
|
|
}
|
|
fflush(stderr);
|
|
return cstat;
|
|
}
|