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
russ@xxxxxxxxxxxxxxxx P.O. Box 3000
http://www.unidata.ucar.edu/ Boulder, CO 80307-3000
______________________________________________________________________________