[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: anybody got c++ code working?
- Subject: Re: anybody got c++ code working?
- Date: Wed, 13 Jul 1994 16:10:38 -0600
> Organization: Oceanography Department
> Keywords: 199407131858.AA05121
Hi Dan,
> I recently downloaded netcdf version 2.3.2, and have been successful
> in using everything but the C++ interface. The Makefile in the c++
> directory dies, complaining as in the error messages I pasted below.
> It fails whether I use 'g++' or the ATT compiler.
>
> I'm writing to ask whether anybody else has been successful in getting
> the C++ stuff working.
A change made to the netcdf.h file for the 2.3.2 revision broke the C++
interface. We didn't notice this at the time, because the experimental C++
stuff was not compiled or tested automatically as part of our testing of a
new release. The problem was that the C++ interface already had a typedef
for ncbyte (as unsigned char), and the 2.3.2 revisions to netcdf.h added a
new, conflicting, and unnecessary typedef for ncbyte.
Thus if you merely delete the statement
typedef char ncbyte;
from netcdf.h, the C++ interface should compile OK.
Since netcdf.h is actually generated from netcdf.h.in during installation,
the deletion should really be made to netcdf/libsrc/netcdf.h.in also. I've
appended a patch for this and all the other small bugs discovered so far in
the netcdf C++ interface. Please let me know if you run into any more.
Thanks.
--
Russ Rew UCAR Unidata Program
address@hidden P.O. Box 3000
http://www.unidata.ucar.edu/ Boulder, CO 80307-3000
This is a patch for the experimental C++ interface to netCDF in version
2.3.2pl2 (April 1994).
This patch accomplishes the following:
BUG FIXES
A bug in netcdf.h that prevented correct compilation of the experimental
C++ interface is fixed by removing typedefs for ncchar, ncbyte, ncshort,
ncfloat, and ncdouble.
Fixed off-by-one problem with strings reported by Tom Lefebvre.
Minor changes to work with g++.
Added put and get functions for ncbyte arrays.
Fixed a bug in NcVar::get_att(NcToken) member, to make it return 0 for
attributes that don't exist.
NcAtt::is_valid() had been returning FALSE for global attributes, but this
fix makes it return TRUE when appropriate.
This patch-file is designed to be applied from the top-level netcdf source
directory via Larry Wall's patch(1) utility, e.g.
$ cd /usr/local/src/netcdf-2.3.2
$ patch < this_file
===================================================================
diff -c1 -r libsrc/netcdf.h.in
*** oldlibsrc/netcdf.h.in Tue Jun 8 13:20:36 1993
--- libsrc/netcdf.h.in Wed Jul 21 12:36:23 1993
***************
*** 16,18 ****
*/
! /* "$Id: netcdf.h.in,v 1.3 1993/06/08 19:22:22 steve Exp $" */
--- 16,18 ----
*/
! /* "$Id: netcdf.h.in,v 1.4 1993/07/21 18:36:23 steve Exp $" */
***************
*** 278,282 ****
*/
- typedef char ncchar;
- typedef char ncbyte;
- typedef short ncshort;
#ifdef __alpha
--- 278,279 ----
***************
*** 291,294 ****
#undef NCLONG_DEFINED
- typedef float ncfloat;
- typedef double ncdouble;
--- 288,289 ----
diff -c1 -r c++/ncvalues.cc
*** oldc++/ncvalues.cc Thu Apr 15 15:41:03 1993
--- c++/ncvalues.cc Fri Aug 6 11:13:55 1993
***************
*** 6,8 ****
*
! * $Header: /a/zero/home/russ/src/netcdf/c++/RCS/ncvalues.cc,v 1.9
1993/04/15 21:41:40 russ Exp $
*********************************************************************/
--- 6,8 ----
*
! * $Header: /upc/new/CVS/netcdf/c++/ncvalues.cc,v 1.10 1993/08/06 17:13:55
russ Exp $
*********************************************************************/
***************
*** 156,158 ****
{
! return strdup((char*)the_values + n);
}
--- 156,161 ----
{
! char *s = new char[the_number + 1];
! s[the_number] = '\0';
! strncpy(s, (const char *)the_values + n, (int)the_number);
! return s;
}
***************
*** 161,163 ****
{
! return strdup(the_values + n);
}
--- 164,169 ----
{
! char *s = new char[the_number + 1];
! s[the_number] = '\0';
! strncpy(s, (const char *)the_values + n, (int)the_number);
! return s;
}
diff -c1 -r c++/netcdf.cc
*** oldc++/netcdf.cc Sun Apr 25 10:23:53 1993
--- c++/netcdf.cc Tue Feb 22 11:09:42 1994
***************
*** 6,8 ****
*
! * $Header: /a/zero/home/russ/src/netcdf/c++/RCS/netcdf.cc,v 1.42
1993/04/25 16:24:28 russ Exp $
*********************************************************************/
--- 6,8 ----
*
! * $Header: /upc/new/CVS/netcdf/c++/netcdf.cc,v 1.46 1994/02/22 18:09:42
russ Exp $
*********************************************************************/
***************
*** 208,210 ****
! enum NcFile::FillMode NcFile::get_fill( void )
{
--- 208,210 ----
! NcFile::FillMode NcFile::get_fill( void )
{
***************
*** 493,494 ****
--- 493,498 ----
NcAtt* att = new NcAtt(the_file, this, aname);
+ if (! att->is_valid()) {
+ delete att;
+ return 0;
+ }
return att;
***************
*** 562,563 ****
--- 566,568 ----
+ NcVar_put_array(ncbyte)
NcVar_put_array(char)
***************
*** 582,583 ****
--- 587,589 ----
+ NcVar_put_nd_array(ncbyte)
NcVar_put_nd_array(char)
***************
*** 621,622 ****
--- 627,629 ----
+ NcVar_get_array(ncbyte)
NcVar_get_array(char)
***************
*** 641,642 ****
--- 648,650 ----
+ NcVar_get_nd_array(ncbyte)
NcVar_get_nd_array(char)
***************
*** 672,673 ****
--- 680,682 ----
}
+ return TRUE;
}
***************
*** 849,851 ****
return the_file->is_valid() &&
! the_variable->is_valid() &&
ncattinq(the_file->id(), the_variable->id(), the_name, 0, 0) != ncBad;
--- 858,860 ----
return the_file->is_valid() &&
! (the_variable->id() == NC_GLOBAL || the_variable->is_valid()) &&
ncattinq(the_file->id(), the_variable->id(), the_name, 0, 0) != ncBad;
diff -c1 -r c++/netcdf.hh
*** oldc++/netcdf.hh Sun Apr 25 10:23:11 1993
--- c++/netcdf.hh Tue Dec 7 09:17:48 1993
***************
*** 6,8 ****
*
! * $Header: /a/zero/home/russ/src/netcdf/c++/RCS/netcdf.hh,v 1.39
1993/04/25 16:23:51 russ Exp $
*********************************************************************/
--- 6,8 ----
*
! * $Header: /upc/new/CVS/netcdf/c++/netcdf.hh,v 1.40 1993/12/07 16:17:48
russ Exp $
*********************************************************************/
***************
*** 243,244 ****
--- 243,246 ----
// returned if type of values does not match type for variable.
+ NcBool put( const ncbyte* vals,
+ long c0=0, long c1=0, long c2=0, long c3=0, long c4=0 );
NcBool put( const char* vals,
***************
*** 258,259 ****
--- 260,262 ----
// may be reset with set_cur().
+ NcBool put( const ncbyte* vals, const long* counts );
NcBool put( const char* vals, const long* counts );
***************
*** 269,270 ****
--- 272,275 ----
// default, but may be reset using the set_cur() member.
+ NcBool get( ncbyte* vals, long c0=0, long c1=0,
+ long c2=0, long c3=0, long c4=0 ) const;
NcBool get( char* vals, long c0=0, long c1=0,
***************
*** 284,285 ****
--- 289,291 ----
// may be reset with set_cur().
+ NcBool get( ncbyte* vals, const long* counts ) const;
NcBool get( char* vals, const long* counts ) const;