This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: cpp behaviour change


On Thu, Jun 22, 2000 at 01:41:56AM +0200, Falk Hueffner wrote:
> Hi,
> 
> I found out that this:
> 
> #define FOO(V) printf("baz " ## #V);
> FOO(bar);
> 
> will be converted by cpp 2.96 to
> 
> printf("baz "#bar);;
> 
> while 2.95.2 produced
> 
> printf("baz ""bar"); ;
> 
> Can anybody tell me which behaviour is correct?

C99 section 6.10.3.2 paragraph 2: ... The order of evaluation of # and
## operators is unspecified.

The current cpp chooses to go strictly left-to-right; the older one
did all the # operators first.  Either choice is allowed.

If this fragment is intended to be fed to the C compiler, then the ##
is unnecessary.  You can put as much whitespace as you want (including
comments) between consecutive string constants, and they will still be
pasted.

If you are using cpp to process something other than C source, please
use M4 instead.

zw

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]