mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-27 08:49:16 +08:00
1a7531392f
Primary fixes to get -ansi to work. 1. Convert all '//' C++ style comments to /*...*/ or to use #if 0...#endif 2. It turns out that when -ansi is specified, then a number of functions no longer are defined in the header -- but they are still in the .so file.<br> The big example is strdup(). So, added code to include/ncconfig.h to define externs for those missing functions that occur in more than one place. These are enabled if !_WIN32 && __STDC__ == 1 (__STDC__ is supposed to be the equivalent compile time flag to -ansi). Note that this requires config.h (which references ncconfig.h) to be included in files where it is currently not included. Single uses will be only in the file that uses them. 3. Added mmap test for the MAP_ANONYMOUS flag to configure.ac. Apparently this is not always defined with -ansi. 4. fix some large integer constants in nc_test4/tst_atts3.c and nc_test4/tst_filterparser.c to avoid compiler complaints. 5. fix a double constant in nc_test4/tst_filterparser.c to avoid compiler complaints. [Note I suspect #4 and #5 will be a problem on big-endian machines, but we have no way to test] Misc. Changes: 1. convert more instances of _MSC_VER to _WIN32. 2. added some debugging code to include/nctestserver.h 3. added comment about libdispatch/drc.c always being compiled. 4. modify parser generation in ncgen to remove unneeded files.
56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
/*********************************************************************
|
|
* Copyright 2016, UCAR/Unidata
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
*********************************************************************/
|
|
|
|
/**
|
|
Test the netcdf-4 data building process.
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "netcdf.h"
|
|
|
|
static void
|
|
fail(int code)
|
|
{
|
|
if(code != NC_NOERR)
|
|
fprintf(stderr,"***Fail: %s\n",nc_strerror(code));
|
|
exit((code==NC_NOERR?EXIT_SUCCESS:EXIT_FAILURE));
|
|
}
|
|
|
|
int
|
|
main(int argc, char** argv)
|
|
{
|
|
int ret = NC_NOERR;
|
|
char url[4096];
|
|
int ncid;
|
|
|
|
/* Skip cmd name */
|
|
argc++;
|
|
argv++;
|
|
|
|
if(argc < 2) {
|
|
fprintf(stderr, "too few arguments: t_dmrdata.c <infile> <outfile>\n");
|
|
fail(NC_NOERR);
|
|
}
|
|
|
|
/* build the url */
|
|
snprintf(url,sizeof(url),"file://%s#dap4&debug=copy&substratename=%s",argv[0],argv[1]);
|
|
|
|
#ifdef DEBUG
|
|
fprintf(stderr,"t_dmrbuild %s -> %s\n",url,outfile);
|
|
#endif
|
|
|
|
/* Use the open/close mechanism */
|
|
if((ret=nc_open(url,NC_NETCDF4,&ncid))) goto done;
|
|
if((ret=nc_close(ncid))) goto done;
|
|
|
|
done:
|
|
#ifdef DEBUG
|
|
fprintf(stderr,"code=%d %s\n",ret,nc_strerror(ret));
|
|
#endif
|
|
return (ret ? 1 : 0);
|
|
}
|