This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
-pedantic and typedef inheritance.
- To: gcc at gcc dot gnu dot org
- Subject: -pedantic and typedef inheritance.
- From: Gerhard Esterhuizen <goof at dsp dot sun dot ac dot za>
- Date: Sat, 8 Jan 2000 12:40:40 +0200 (SAST)
Hi,
I have a piece of code that contains a typedef in a templated base class
that seems to inherit down to the the derived class depending on whether
or not I use the -pedantic flag. Does this indicate that my code is wrong
(non ANSI/ISO) or should I not use the pedantic flag ?
Compiler is egcs-1.1.2 (RedHat Linux 6.1) on Intel PII. If I compile using
-Wall -ansi
it works perfectly well, but a parse error is reported if I try it with
-Wall -ansi -pedantic
Compiler output:
[goof@pablo:~/devel/tmp]$ g++ -Wall -ansi -pedantic -c -o ttd3.o ttd3.cc
ttd3.cc: In method `void Derived3<_TD>::DerFunc()':
ttd3.cc:18: parse error before `=
Sample code:
template<typename _TB>
struct Base3 {
int baseData;
void BaseFunc(void);
typedef int T_Generic;
};
template<typename _TD>
struct Derived3 : public Base3<Derived3<_TD> > {
_TD derData;
void DerFunc(void) {
// inherits base class data: OK
baseData = 1;
// inherits base class function: OK
BaseFunc();
// compiler gives parse ERROR because T_Generic
// does not inherit. Why ?
T_Generic t = 2;
}
};
Gerhard Esterhuizen <gesterhuizen@bigfoot.com>
Digital Signal Processing
University of Stellenbosch
South Africa
+27-21-808-4315
"You will never be happy if you continue to search for what happiness
consists of.
You will never live if you are looking for the
meaning of life."
--Albert Camus
(1913 - 1960)