Supported C++ libraries

Rupert Wood me@rupey.net
Wed Oct 17 23:57:00 GMT 2001


Inna Routgauzer wrote:

> I'm looking for C++ compiler for SUN SparcStation.
> If I'll download gcc 3.0.1 would it recognize such types as:
> string, list, vector,..

Yes and no.

Firstly, you hopefully know that you won't find a C++ compiler binary on
the GCC site - only source so that you can rebuild from an existing
compiler. If you're running Solaris on your SparcStation then try
http://www.sunfreeware.com/

Secondly, string list and vector are not built-in types (in this or in
any C++ compiler). You need to include the relevant Standard Template
Library header (STL) files to use these types. The STL header files are
included with GCC (as part of libstdc++-v3). However, GCC 3 follows the
C++ standard by defining these three types inside the 'std' namespace,
so you either have to address them 'std::string' etc. or import them
from the std namespace at the start of your program:

        #include <string>
        #include <vector>
        #include <list>

        using std::string;
        using std::vector;
        using std::list;

or import the whole std namespace:

        #include <string>
        #include <vector>
        #include <list>

        using namespace std;

(I personally prefer the individual imports, but I guess it's up to
you.)

Finally, when you're compiling and linking C++ code, make sure you
invoke 'g++' and not 'gcc'.

Good luck,
Rup.



More information about the Gcc-help mailing list