Re: The inclusion of <string> makes the word `minor' special (g++)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 06, 2004 at 10:13:51AM +0800,
 Edward L. Fox probably wrote:
> Hi all:
> 
>     I expanded all macros in that testing file by "gcc -E" and couldn't find
> any macro declaration about "minor" in the expanded code.

The #define's are stripped by the preprocessor, so you'd see nothing.

> And it was so
> strange that the "minor" in "class minor" didn't changed, but the ctor
> declaration did.
> 
>     Anybody tell me why?
> 

Maybe because the latter has () after it, and the macro has parameters?

> 
>                 Edward L. Fox
> 
>                 2004-10-06
>  
> 
> From: edyfox@xxxxxxxx
> 
> 
> On Wed, 6 Oct 2004 05:39:23 +0800, Edward L. Fox <edyfox@xxxxxxxxx> wrote:
> > Very interesting... :-)
> > 
> > class minor
> > {
> >        int i;
> > 
> > public:
> >        minor:i(0){}
> > };
> > 
> > ====>
> > 
> > class minor
> > {
> >        int i;
> > 
> > public:
> >        ((int)(() & 0xff)):i(0){}
> > };
> > 
> > 
> > 
> > On Tue, 5 Oct 2004 17:05:04 +0400, Sergey Zaharchenko
> > <doublef@xxxxxxxxxxx> wrote:
> > > Hello list,
> > >
> > > I'm not sure whether it is a bug, or I am overlooking something, but I
> > > have the problem best described by this printout (with and without the
> > > #include):
> > >
> > > Script started on Tue Oct  5 16:41:54 2004
> > > $ g++ -v
> > > Using built-in specs.
> > > Configured with: FreeBSD/i386 system compiler
> > > Thread model: posix
> > > gcc version 3.4.2 [FreeBSD] 20040728
> > > $ cat 1.cc
> > > class minor
> > > {
> > >        int i;
> > >
> > > public:
> > >        minor():i(0){}
> > > };
> > >
> > > int
> > > main(void)
> > > {
> > > }
> > > $ cat 2.cc
> > > #include <string>
> > >
> > > class minor
> > > {
> > >        int i;
> > >
> > > public:
> > >        minor():i(0){}
> > > };
> > >
> > > int
> > > main(void)
> > > {
> > > }
> > > $ g++ 1.cc
> > > $ g++ 2.cc
> > > 2.cc:8: error: expected unqualified-id before "int"
> > > 2.cc:8: error: expected `)' before "int"
> > > 2.cc:8: error: expected `)' before "int"
> > >
> > > FWIW, g++ 2.95.4 doesn't barf at any of the sources.
> > >
> > > If I change the name `minor' to something else, everything works. But
> > > what if I happen to like the name:)?
> > >
> > > Please CC me in any replies.
> > >
> > > TIA,
> > >
> > > --
> > > DoubleF
> > > "Humor is a drug which it's the fashion to abuse."
> > >                -- William Gilbert
> > >
> > >
> > >
> >

-- 
DoubleF
Gosh that takes me back... or is it forward?  That's the trouble with
time travel, you never can tell."
		-- Dr. Who, "Androids of Tara"

Attachment: pgpHxhDY2eZza.pgp
Description: PGP signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux