[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SGI C++ compiler and netcdf reply



Greg,

Russ Rew asked me to look into the problem of compiling with netCDF
on your SGI.  Here is some of what I found, though I may not
have the final answer for you.

First, this simple program WILL compile and run with no warnings
or errors on our SGI machines. Note that netcdf is included. Note
also that the older form of "include" (with the .h) is used,
and -LANG:std is not used in the compile command and there is no 
use of namespace.

// really_simple_nstd.cpp succeeds on SGI with command
// CC -o test -I/upc/netcdf/include really_simple_nstd.cpp
#include <iostream.h>
#include <string.h>
#include "netcdfcpp.h"

int main() {
    cerr << "This has gotta work; 3, simple cerr." << endl;
    return 0;
  }



Second, here is a case closer to your reported error using -LANG:std
and the newer form of include and namespace. But with no use of netcdf.

// various forms make compiler errors or warnings:  really_simple.cpp
// command CC -LANG:std -o test really_simple.cpp
#include <string>
#include <iostream>
using namespace std;

int main() {
    cerr << "This has gotta work, simple cerr." << endl;
    // string str(" string output: This has gotta work, too.");  
    // cerr << str << endl;                                     
    return 0;
  }


As shown it compiles, with ("fatal"?) warnings, and runs. 
With the one line "string str..."  uncommented it fails to compile. 

In fact almost any variation on this code, when -LANG:std and the
newer form of include is used, makes either compile-time errors or failures,
without netcdf being involved in any way. True you can make even more errors
by trying to include netcdf but perhaps the C++ errors ought to be
considered first.  It clearly can't sort out the connection between
cerr, string, and so on, before netcdf is brought in. 

There appears to be a bug in the SGI compiler when used with newer
include forms and namespaces.


If you can compile your program without -LANG:std and without the
newer include form and namespaces, that should get you going. 

Stu Wier

PS this next program works fine when compiled with g++, and 
does use the newer form of include, namespace, and netcdf, all three.
Note it also uses both cerr and string, a combination I
was unable to get to work in any way with the CC -LANG:std compile

// program really_simple2.cpp fails on to compile on SGI with command
// CC -LANG:std -o test really_simple2.cpp  even WITHOUT #include "netcdf.h"
// SUCCEEDS with g++ -o test -I/upc/netcdf/include really_simple2.cpp  , with
netcdf.
#include <string>
#include <iostream>
using namespace std;
#include "netcdfcpp.h"

int main() {
    cerr << "This has gotta work. simple cerr." << endl;
    string str("This has gotta work, too.");  // **********
    cerr << str << endl;                                   
    return 0;
  }


Based on this one case, gcc and g++ might be a good compiler to use.

-------------------------------------------------------------------------
Stuart Wier                           UCAR Unidata Program Center
address@hidden                        P.O. Box 3000
(303) 497-8659                              Boulder, CO 80307
Unidata Home Page                     http://www.unidata.ucar.edu/