public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Change in preprocessor behavior
@ 2002-12-30 20:53 Stephen Lindholm
  2002-12-30 20:54 ` Neil Booth
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Stephen Lindholm @ 2002-12-30 20:53 UTC (permalink / raw)
  To: gcc


The stringize and token-pasting operators seem to no longer work in the
"cpp" phases of compilation, but they worked in "cpp" in early versions of
gcc (2.95.3). I can't find it written that those operations must occur in
phases 1-4, but # and ## are "preprocessing-op-or-punc" and it would seem
that they should therefore be processed in phase 4.

Am I doing something wrong?


Using this example from the cpp info page:

#define COMMAND(NAME)  { #NAME, NAME ## _command }
      
struct command commands[] =
{
  COMMAND (quit),
  COMMAND (help),
};

I get this as expected on an old version of cpp (2.95.3):

Xenon > cpp test2
# 1 "test2"

      
struct command commands[] =
{
  { "quit",  quit_command } ,
  { "help",  help_command } ,
};

and this on a new version of cpp (3.1):

thrush:~% cpp test2
# 1 "test2"

      
struct command commands[] =
{
  { #quit, quit ## _command },
  { #help, help ## _command },
};


^ permalink raw reply	[flat|nested] 12+ messages in thread
* RE: Change in preprocessor behavior
@ 2002-12-31 10:24 Martin York
  0 siblings, 0 replies; 12+ messages in thread
From: Martin York @ 2002-12-31 10:24 UTC (permalink / raw)
  To: 'Stephen Lindholm', Neil Booth; +Cc: gcc



I may be wrong (I don't have a machine close by with gcc on).

Try adding the -v flag to your compile.
This shows all the flags passed to the underlying frontend (cc1plus)


Then you can compare the flags used on Solaris and OS-X.

You will then be able to see if -traditional is being passed
to cc1plus on your OS-X machine



I also believe you can override the flags passed to the frontend
by specifying a specs file on the command line (though I have never
tried this myself). This may be simpler then rebuilding gcc.


Martin.

-----Original Message-----
From: Stephen Lindholm [mailto:lindholm@CS.Stanford.EDU]
Sent: 30 December 2002 18:46
To: Neil Booth
Cc: gcc@gcc.gnu.org
Subject: Re: Change in preprocessor behavior



I'm using the version of gcc which came with Mac OS X, and I compared it
to the old version of gcc installed on the Solaris mail server. I did not
install either of the two compilers myself.

I did cut and paste the command line and output exactly as they were in
the terminal window.

I guess the OS X compiler came out of the box configured differently than
I expected. I know it has some modifications to support Mac programming,
but I did not expect the preprocessor to be configured differently. I
guess I will just have to use a different computer for my preprocessing or
install another version of gcc.

Thank you for your help.


On Mon, 30 Dec 2002, Neil Booth wrote:

> Stephen Lindholm wrote:-
> 
> > thrush:~% cpp test2
> > # 1 "test2"
> > 
> >       
> > struct command commands[] =
> > {
> >   { #quit, quit ## _command },
> >   { #help, help ## _command },
> > };
> 
> Contrary to your claim, I suspect you're using cpp -traditional, no?
> 
> Traditional preprocessors did not support # and ##, and 3.1 is more
> "correct" in this respect.  FWIW 3.3 has another new implementation of
> traditional preprocessing which is the most faithful of GCC's
> implementations to true traditional preprocessing.
> 
> Neil.
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Change in preprocessor behavior
@ 2022-06-21  0:34 Dave Blanchard
  2022-06-21  7:28 ` Richard Biener
  0 siblings, 1 reply; 12+ messages in thread
From: Dave Blanchard @ 2022-06-21  0:34 UTC (permalink / raw)
  To: gcc

At some point between GCC 9 and GCC 12, the preprocessor started behaving differently. Before if GCC were launched as /lib/cpp or /usr/bin/cpp (I think) it would assume the user wanted to preprocess something and automatically launch in preprocessor mode. Now the behavior has changed and it just acts as the normal compiler. Can someone kindly point me to the patch or commit where this feature was changed, and the rationale for doing so? Thank you.

-- 
Dave Blanchard <dave@killthe.net>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-06-21 12:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-30 20:53 Change in preprocessor behavior Stephen Lindholm
2002-12-30 20:54 ` Neil Booth
2002-12-30 20:54   ` Stephen Lindholm
2003-01-02 21:04   ` Devang Patel
2002-12-30 20:54 ` Neil Booth
2003-01-02 20:42 ` Mike Stump
2003-01-02 21:02   ` Devang Patel
2003-01-04 20:19 ` Zack Weinberg
2002-12-31 10:24 Martin York
2022-06-21  0:34 Dave Blanchard
2022-06-21  7:28 ` Richard Biener
2022-06-21 12:57   ` Dave Blanchard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).