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: Harsh Anand <address@hidden> >Subject: netcdf 3.5-beta3 installation problem on IBM SP >Organization: LBNL/NERSC >Keywords: 200008022147.e72LljT08254 netCDF 3.5-beta3 Hi Harsh, > I got errors like > > xlC -c -I../libsrc -I. -DNDEBUG netcdf.cpp > "netcdfcpp.h", line 156.10: 1540-0133 (S) The attributes "friend" are > not allowed. > > installing C++ interface on the IBM SP3 we have at NERSC Lawrence > Berkeley Lab: > > FYI -- IBM tech support folks tell me that it is not a bug. According > to the > standard "The attributes "friend" are not allowed". Could you > please suggest any workaround for this problem? > I have successfully compiled this program using KAI C++ compiler. See a previous message for a workaround: http://www.unidata.ucar.edu/glimpse/netcdf/3814 But I don't understand how this could be non-standard C++. The draft standard available from http://www.cygnus.com/misc/wp/dec96pub/access.html includes the following example: 4 When a friend declaration refers to an overloaded name or operator, only the function specified by the parameter types becomes a friend. A member function of a class X can be a friend of a class Y. [Exam- ple: class Y { friend char* X::foo(int); // ... }; which uses the same syntax we use. Is it that you can't declare a private constructor to be a friend? If so, I haven't seen that restriction explicitly stated anywhere. Can you find out where in the standard this syntax is disallowed, since no other C++ compiler we have tried objects to it? A less heavy-handed workaround would be to declare the whole NcFile class to be a friend rather than just particular member functions, that is use friend NcFile; instead of friend NcFile::NcFile( const char *, FileMode, size_t*, size_t); friend NcBool NcFile::sync( void ); friend NcDim* NcFile::add_dim( NcToken, long ); // to delete dimensions, since destructor is private friend NcBool NcFile::close( void ); and similarly for other places where the compiler objects to the declarations of particular member functions as friends. But I don't understand why this should be necessary ... --Russ