From: stephan b. <sg...@us...> - 2004-12-22 19:06:17
|
Update of /cvsroot/pclasses/pclasses2/toc/tests/cpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7192/cpp Added Files: check_setenv_in_cpp.cpp check_stl_newstyle.cpp gcc_2_95_typename_problem.cpp Makefile Log Message: egg --- NEW FILE: check_setenv_in_cpp.cpp --- #include <stdlib.h> /** On the solaris boxes i have i can't compile this as c++, but can as c, using gcc 2.95.3: /opt/gnu/bin/gcc toc/tests/cpp/check_setenv_in_cpp.cpp -c -o .toc.try_compile.o toc/tests/cpp/check_setenv_in_cpp.cpp: In function `int main()': toc/tests/cpp/check_setenv_in_cpp.cpp:9: implicit declaration of function `int setenv(...)' */ int main() { setenv( "foo", "foo", 1 ); return 0; } --- NEW FILE: check_stl_newstyle.cpp --- #include <sstream> int main() { std::ostringstream os; os << "foo"; return 0; } --- NEW FILE: Makefile --- include toc.make DIST_FILES += $(wildcard *.cpp *.c) all: --- NEW FILE: gcc_2_95_typename_problem.cpp --- #include <map> using namespace std; #ifndef TYPENAME #define TYPENAME typename // gcc 3.x accepts typename, gcc 2.95.3 does not #endif template <typename T> struct Foo { typedef T TT; typedef Foo<TT> ThisType; typedef map<ThisType::TT,ThisType::TT> map_type; /** gcc 2.95.3 will do something like the following: stl_check.cpp: In method `void Foo<T>::check_for_gcc2_9_failure(const map<T,T,less<_Key>,allocator<_Tp1> > &)': stl_check.cpp:15: no class template named `map' in `struct Foo<T>' stl_check.cpp:16: no class template named `map' in `struct Foo<T>' gcc 3.x (3.3pre, at least) swallows it nicely. The problem here is the 'typename' part: without that gcc 2.95.3 compiles it fine. gcc 3, however, warns that "implicite typenames are deprecated", and this kills my builds (i always use -Werror :/). */ void check_for_gcc2_9_failure() { ThisType::map_type map; TYPENAME ThisType::map_type::const_iterator it = map.begin(); TYPENAME ThisType::map_type::const_iterator et = map.end(); for( ; it != et; ++it ) {} } }; int main() { typedef Foo<int> Fii; Fii fii; fii.check_for_gcc2_9_failure(); return 0; } |