 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
SK Guest
|
Posted: Wed Aug 13, 2003 4:33 pm Post subject: Which compiler is correct? |
|
|
Consider this code:
class A{
public:
class {
public:
int i;
};
};
int main ()
{
}
This code compiles fine with VC 7.0 and g++ 3.2.
It fails with Comeau online though.
What does the standard have to say about unnamed nested classes?
Thanks.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
Daniel Frey Guest
|
Posted: Wed Aug 13, 2003 5:45 pm Post subject: Re: Which compiler is correct? |
|
|
SK wrote:
| Quote: | What does the standard have to say about unnamed nested classes?
|
Comeau is correct. The only valid use of unnamed classes/structs is to
declare a typedef or name a variable, which you haven't done in your
example. Whether or not the class is a nested class is irrelevant.
Regards, Daniel
--
Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: [email]daniel.frey (AT) aixigo (DOT) de[/email], web: http://www.aixigo.de
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
Carl Daniel Guest
|
Posted: Thu Aug 14, 2003 6:55 pm Post subject: Re: Which compiler is correct? |
|
|
"SK" wrote:
| Quote: | Consider this code:
class A{
public:
class {
public:
int i;
};
};
int main ()
{
}
This code compiles fine with VC 7.0 and g++ 3.2.
It fails with Comeau online though.
|
VC6, VC7 and VC7.1 flag this as an error if you compile with -Za (disable
extensions), and gives a wanring (non-standard extension used) if you
compile with -W4.
Comeau is correct according to the standard.
-cd
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
llewelly Guest
|
Posted: Sat Aug 16, 2003 5:07 pm Post subject: Re: Which compiler is correct? |
|
|
[email]sk (AT) sk (DOT) com[/email] ("SK") writes:
| Quote: | Consider this code:
class A{
public:
class {
public:
int i;
};
};
int main ()
{
}
This code compiles fine with VC 7.0 and g++ 3.2.
It fails with Comeau online though.
|
g++ -pedantic -W -Wall cl2.cc
cl2.cc:7: warning: ISO C++ prohibits anonymous structs
If you want an error, use -pedantic-errors.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|