Serious error-causing change in new CPP's -traditional behavior

Dave Brolley brolley@redhat.com
Fri May 12 10:37:00 GMT 2000


Richard Earnshaw wrote:

> > Zack Weinberg wrote:
> >
> > > On Thu, May 11, 2000 at 05:03:46PM +0100, Richard Earnshaw wrote:
> > > > What I would like to have is
> > > >
> > > > #define wibble(foo) mov       r0, # foo
> > > > .text
> > > > a:
> > > >       wibble(4)
> > > >
> > > > and get the output
> > > >
> > > > .text
> > > > a:
> > > >         mov r0, #4
> > > >
> > > > Unfortunately we get
> > > >
> > > >       mov r0, "4"
> > >
> > > Alas, this may not have been what you intended, but it is the behavior
> > > mandated by the standard for that #define.  Whitespace between the
> > > stringize operator and its argument (macro name) is not significant.
> > > I don't plan to change this in assembly language mode.
> >
> > This should be made to work as Richard expects for  -traditional
> >
> > Dave
> >
>
> True, but in this context we were talking about what would happen if we
> stopped using -traditional for assembly.
>
> FWIW, I don't disagree with Zack here; this is just a gotcha that must be
> watched for; with the recent patches applied, there are now several viable
> alternatives for getting the desired output.

In that case, I agree with Zack. You need to code something like:

#define HASH #    /* '#' isn't special on object-like macros */
#define LPREFIX() HASH
#define wibble (foo) mov    r0, LPREFIX()foo
wibble (4)

This will also have the benefit of allowing you to change the literal prefix
easily for different assemblers.

Dave



More information about the Gcc-bugs mailing list