This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Paul, > We use netcdf for gridded files used by the Generic Mapping Tools (GMT), > a package used by ~5000 scientists around the world. We just released a beta > version of 3.0 and have received several letters about compile problems which > seem to be caused by the removal of several typedefs in the netcdf.h file: > > typedef char ncchar ; > typedef char ncbyte ; > typedef short ncshort ; > typedef float ncfloat ; > typedef double ncdouble; > > Are these no longer used by netcdf? We have code that uses the nc* notation. > What fix do you recommend? These typedefs were never documented for use and were added by mistake in the netCDF 2.3.2 release. I've appended a note I sent out in February discussing how to deal with this problem. If we decide to add these back in the netCDF 2.4 release, the "ncchar" typedef would have to be changed to agree with the C++ interface. --Russ To: address@hidden (John Huddleston) Subject: Re: c++ library for netCDF In-Reply-To: Your message of "Mon, 06 Feb 1995 08:49:40 MST." <address@hidden> Organization: UCAR Unidata Program Date: Mon, 06 Feb 1995 13:09:46 -0700 From: Russ Rew <address@hidden> John Huddleston wrote: > I recompiled the Gnu C++ compiler version 2.6.3 on > my system. Once completed I started in again on > the compilation of the c++ library. > > There was a conflict in two header files for > the same variable. In line 281 on the libsrc/netcdf.h > and line 20 of the c++/ncvalues.hh files > the definitions are different. I changed > the libsrc/netcdf.h line from > > typedef char ncbyte; > to > typedef unsigned char ncbyte; > > and the c++ library compiled nicely. I am not > sure what the impact will be on the netCDF > C library with this change. Do you? Sorry, I neglected to point out that after applying the patches, it is necessary to remake the netCDF library from scratch (from the `configure' step), because the libsrc/netcdf.h file is regenerated by the `configure' script from one of the files changed by the patch. If you had done this, it would have generated a new netcdf.h file without the incorrect typedef for `ncbyte'. This typedef is not documented as part of the C interface, not used by other netCDF software that uses the C interface, and users should avoid using it in their own programs. By way of explanation, this problem first occurred with the netCDF 2.3.2 release, when we found it necessary to add a typedef `nclong' to replace the use of the `long' declaration for netCDF long data (but not for dimension sizes, indices, or strides, which should still use type `long') in order to port the netCDF library to DEC Alpha platforms. At the time version 2.3.2 was released, we sent a message to the netcdfgroup mailing list about the necessity for using `nclong' for data declared of type NCLONG to make C applications portable to 64-bit platforms like the DEC Alpha. At the same time, some additional typedefs were mistakenly added for the other netCDF types, including the `ncbyte' typedef (as a char) that clashed with a typedef already used in the experimental C++ interface (as an unsigned char). When we discovered this, we issued a patch (patch 3 to netCDF version 2.3.2) that removed the undocumented additional typedefs from the `netcdf.h.in' file from which `netcdf.h' is generated. Had we tested the experimental C++ interface after the new typedefs were added, we would have discovered the problem, but since it was experimental and there weren't very many sites with C++ compilers in June 1993, it was not included in the release tests. Ideally, you should have only typedef long nclong; in netcdf.h, but no typedefs for `ncchar', `ncbyte', `ncshort', `ncfloat', or `ncdouble'. As it says in comments in netcdf.h currently, for platforms that support 64-bit longs this will ultimately be changed to typedef int nclong; when the library, documentation, and examples are modified to use `nclong' declarations. If you use `nclong' for declaring data stored using the NCLONG netCDF data type, your programs will continue to work across this change on platforms that use 32-bit longs and will work -- after recompilation -- on platforms that use 64-bit longs. If you want to use your own typedefs for netCDF types and avoid clashing with future library interfaces, use other names for your types, for example `nc_byte', `nc_short', ..., `nc_double'. ______________________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden P.O. Box 3000 http://www.unidata.ucar.edu/ Boulder, CO 80307-3000 ______________________________________________________________________________