This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

STL in G++?


This may be a stupid question, but I didn't find anything by googling 
gcc, g++, STL. So:

There are no STL header files in some versions of g++: 
The program works on some g++'s, but not on others:




#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;

template <class T>
class PrintGt5: public unary_function<T, void>
{
public: 
        PrintGt5(){}
        void operator()(T a) { if (a > T(5)) cout << a << ' '; }
};

main()
{
        int ar [10], i;

        for(i=0; i < 10; i++) ar[i] = i;

        for_each(ar, ar+10, PrintGt5<int>());
        cout << endl;

        return 0;
}
[root@dakota asn1]# g++ stl.cpp
stl.cpp:1:21: algorithm: No such file or directory
stl.cpp:2:20: iostream: No such file or directory
stl.cpp:3:22: functional: No such file or directory
stl.cpp:8: error: expected template-name before '<' token
stl.cpp:8: error: expected `{' before '<' token
stl.cpp:8: error: expected unqualified-id before '<' token
stl.cpp: In function `int main()':
stl.cpp:21: error: invalid use of undefined type `class PrintGt5<int>'
stl.cpp:8: error: declaration of `class PrintGt5<int>'
stl.cpp:21: error: `for_each' was not declared in this scope
stl.cpp:22: error: `cout' was not declared in this scope
stl.cpp:22: error: `endl' was not declared in this scope


STLport also won't compile, because it seems to expect _some_ headers
from g++.  I configured gcc for c,c++,ada support.  Version is gcc 
3.4.6 with ada-2005. 


The above program won't work on this:

g++ -v
Reading specs from 
/usr/local/lib/gcc/sparc-unknown-linux-gnu/3.4.6/specs
Configured with: ../gcc-34/configure --enable-shared 
--enable-threads=posix --disable-checking --with-cpu=v7 
--enable-languages=c,c++,ada
Thread model: posix
gcc version 3.4.6 for GNAT GPL 2006 (20060522)



The above program works on this one:

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-shared --enable-threads=posix 
--disable-checking --with-system-zlib --enable-__cxa_atexit 
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)



What's up with STL support in g++?  Is there some add-on for STL?

Thanks,


		--Dean

-- 
Av8 Internet   Prepared to pay a premium for better service?
www.av8.net         faster, more reliable, better service
617 344 9000   



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]