This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Supported C++ libraries
- To: "'Inna Routgauzer'" <inna_routg at hotmail dot com>
- Subject: RE: Supported C++ libraries
- From: "Rupert Wood" <me at rupey dot net>
- Date: Thu, 18 Oct 2001 07:57:16 +0100
- Cc: <gcc-help at gcc dot gnu dot org>
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.