The inclusion of <string> makes the word `minor' special (g++)?
Sergey Zaharchenko
doublef@tele-kom.ru
Wed Oct 6 09:33:00 GMT 2004
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@sohu.com
>
>
> On Wed, 6 Oct 2004 05:39:23 +0800, Edward L. Fox <edyfox@gmail.com> 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@tele-kom.ru> 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"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20041006/44678d09/attachment-0001.sig>
More information about the Gcc-help
mailing list