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.
>To: address@hidden >From: Dave Wood <address@hidden> >Subject: C++ netCDF interface >Organization: Colorado State University >Keywords: 199608072100.AA08938 Hi Dave, > I am trying to write some software using the Win32(MD) library with > MFC and MSVC 4.0. I must have an incomplete set of header files > because the build aborts due to excessive errors. I include > "netcdf.hh" which in turn includes "netcdf.h" and "ncvalues.hh". > Ncvalues.hh includes several more files including "generic.h". My > version of generic.h (which I found under the ncgen directory of the > netCDF 2.4.2 release) contains only a definition of the generic union. The generic.h in the ncgen directory has nothing to do with the generic.h file that ncvalues.hh wants; it's just an unfortunate name collision from different name spaces. I should rename the generic.h file in ncgen to avoid this confusion. The generic.h referred to in ncvalues.hh was a header file that was included with all the C++ compilation systems I knew about, so I thought we could assume the C++ compiler would find it in a standard place, but I guess that assumption is wrong. I've appended one version of the file (that comes with the GNU g++ compiler) so you can see what it does. Our Sun installation has a copyrighted version in /opt/SUNWspro/SC4.0/include/CC/generic.h and we find it in similar places for compilers from other vendors: /usr/include/CC/generic.h # for HPUX or IRIX > However, the ncvalues.hh header file makes the following note in a > comment: > > // This is the same as the name2 macro from generic.h, but we need to define > // our own version since rescanning something generated with the name2 macro > // won't necessarily cause name2 to be expanded again. > #define ... > > There is no definition of name2 in the generic.h file that I have. This may > not be that > important but _somewhere_ there must be a definition of: > > declare(NcValues,ncbyte) > declare(NcValues,char) > declare(NcValues,short) > declare(NcValues,nclong) > declare(NcValues,float) > declare(NcValues,double) > > which is found at the end of ncvalues.hh. Is this also some sort of > stringizing or token-pasting defined in the lost generic.h? What am I > missing? > - -- Yup, it's for token pasting. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu // This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1988 Free Software Foundation written by Doug Lea (address@hidden) This file is part of the GNU C++ Library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef generic_h #define generic_h 1 /* * See the CPP manual, argument prescan section for explanation */ #define name2(a,b) gEnErIc2(a,b) #define gEnErIc2(a,b) a ## b #define name3(a,b,c) gEnErIc3(a,b,c) #define gEnErIc3(a,b,c) a ## b ## c #define name4(a,b,c,d) gEnErIc4(a,b,c,d) #define gEnErIc4(a,b,c,d) a ## b ## c ## d #define GENERIC_STRING(a) gEnErIcStRiNg(a) #define gEnErIcStRiNg(a) #a #define declare(clas,t) name2(clas,declare)(t) #define declare2(clas,t1,t2) name2(clas,declare2)(t1,t2) #define implement(clas,t) name2(clas,implement)(t) #define implement2(clas,t1,t2) name2(clas,implement2)(t1,t2) //extern genericerror(int,char*); typedef int (*GPT)(int,char*); #define set_handler(gen,type,x) name4(set_,type,gen,_handler)(x) #define errorhandler(gen,type) name3(type,gen,handler) #define callerror(gen,type,a,b) (*errorhandler(gen,type))(a,b) #endif /* generic_h */