This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Template help,To Alexandre Oliva
- To: <gcc at gcc dot gnu dot org>
- Subject: RE: Template help,To Alexandre Oliva
- From: "Shiv Shankar Ramakrishnan" <Shiv at pspl dot co dot in>
- Date: Tue, 14 Nov 2000 09:08:30 +0530
- Cc: <louispp at hotmail dot com>
|you can find such c++ code in VC++.
|in VC++ include directory,the code of file uility
You should read any good book on C++ (Stroustrup) about the rationale
behind the 'typename' keyword. Since that it what has bitten you.
Also see - http://www.ocsltd.com/c++/cpppttyp.html
Such code existing in VC++ includes *does not* mean that -
1. Such code is 'ISO C++'ly correct
2. That the compiler doesn't support the 'typename' keyword
3. That the compiler cannot in theory flag the error
The VC++ compiler does support 'typename'. At least VC6 does. Now its a
different matter that P.J. Plauger and Dinkumware (the implementers of
Std C++ libs for VC++) are not going to give you the correct updated
headers for free. (Complain loudly to them) So the only option I guess
for VC++ was to not flag that as an error. And lets not go into the
whole story behind the mess that Plauger and Tom Plum got all the users
of VC++ into due to their lawsuit ...
|Is there any compile option to avoid the error?
Why don't you try something like this -
#if _MSC_VER >= 1200 //check for the version of your compiler
#define TYPENAME_ typedef
#else
#define TYPENAME_ typename
#endif
template <class T1> struct test01 {
TYPENAME_ T1::Type1 Type1;
};
Its ugly but its one easy way to placate the current situation of
compilers with varying levels of Std ISO C++ support.
I am giving you a detailed answer since most of the other answers that
you have got so far have been very curt ones.
Hope that helps,
Shiv