System V preprocessor problem with <generic.h>

R.B.Murray rbm at sfsup.UUCP
Sat May 3 03:19:51 AEST 1986


> In article <3597 at sun.uucp> sun!guy (Guy Harris) writes:
> >> 	#define name2(a,b)	a/**/b
> >It has, however, two problems:
> >
> >	1) If you run your code through "lint", it won't work
> 
> I tried this example with "cpp -C" and it worked fine.  I'd guess that
> cpp strips all comments in preprocessor directives regardless of "-C".
> 
> >	2) It is not a guaranteed property of the C language, but a
> >	   quirk of the implementation, so it will not work in
> >	   general.
> 
> Agreed.  Any application that depends on being able to do this is treading
> on thin ice.
> 
> Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint

Agreed also.  I also don't believe there 
is a standard and portable way to do this at the present time.
However, the current draft of the ANSI C standard has an
"offical" way to do this:

#define  name2(a,b)	a##b

The "##" is a (new) concatenation operator.
Of course, this is only useful once a standard exists and everybody
conforms to it.  Also, ANSI may change their minds on the syntax of
this feature.

Rob Murray AT&T
Summit, NJ



More information about the Comp.lang.c mailing list