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.
>From: Markus Werle <address@hidden>
>Subject: Non ANSI C++
>Organization: Lehr- und Forschungsgebiet fuer Mechanik, RWTH-Aachen
>Keywords: 199805041934.NAA23467 netCDF g++
Hi Markus,
> I got stuck when trying to use the C++-frontend:
>
> My g++-Compiler (gcc version 2.7.2.3) complains and the program crashes.
>
> [markus@landau] ...netCDF-TEST/FIRST > make
> g++ -g -Wall -I/rayleigh/markus/SOFTWARE/netCDF/netcdf-3.3.1/include
> -I/usr/local/lib/g++-include -c example.C
> example.C: In function `int main()':
> example.C:72: warning: name lookup of `i' changed for new ANSI `for' scoping
> example.C:62: warning: using obsolete binding at `i'
These warnings are only because you included "-Wall", which includes all
warnings. I think they are nothing serious, but will occur for the
second loop below
for(int i = 0; i < 5; i++) {
...
}
for(i = 5; i > 0; i--) {
...
}
after i has been declared in the first loop. Although this used to work
fine, the scope of the i declaration in such cases was changed during
the course of the C++ standardization, so now a warning is issued. The
warning can be eliminated by either declaring i outside both loops or
redeclaring i in the second loop.
> g++ -g -Wall -o test.exe example.o
> -L/rayleigh/markus/SOFTWARE/netCDF/netcdf-3.3.1/lib -L/usr/local/lib
> -lnetcdf_c++ -lnetcdf /opt/langtools/lib/end.o
>
>
> [markus@landau] ...netCDF-TEST/FIRST > ./test.exe
> Bus error
This is a more serious error, and has nothing to do with the warnings
above. I can't tell from this what the problem is, but it could be
caused by pointer errors, exceeding the bounds of an array, etc. You
will have to use a debugger or print statements to isolate where the
problem is occurring. If you find that it's in the netCDF library,
please send a small example that demonstrates the problem.
> By the way: How to bring the whole stuff up with the hp-Compilers?
> They blow off during compiling already ...
I'm not sure what version of netCDF you are using, but the current
version (3.4) and the previous version (3.3.1) work fine with HP
compilers if you follow the instructions in the INSTALL file for HP-UX.
The version before that (2.4.3) had a problem with HP's f77 compiler, a
workaround for which is available from
http://www.unidata.ucar.edu/packages/netcdf/known_problems_243.html
The current version of netCDF is available from
ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-3.4.tar.Z
--Russ
_____________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu