Subject: Re: __STDC__ in cdefs_elf.h
To: None <>
From: Garrett D'Amore <>
List: tech-kern
Date: 09/08/2006 14:38:53
Thor Lancelot Simon wrote:
> On Fri, Sep 08, 2006 at 01:44:11PM -0700, Jason Thorpe wrote:
>> On Sep 8, 2006, at 1:24 PM, Thor Lancelot Simon wrote:
>>> This is because of one of my least-favorite bogosities about the GNU
>>> compilers: they implement C token pasting and stringification in the
>>> C language frontend instead of in the C preprocessor.  This has
>>> annoyed me periodically for about a decade now; I wish it would annoy
>>> someone with more GCC clue sufficiently to fix it!  :-)
>> What?  Nonsense.  Back when it had a separate C preprocessor, it was  
>> certainly implemented there.
> Nope.  I've been flummoxed by this problem with the GCC C preprocessor
> since approximately 1995.  Ask erh if you don't believe me, we spent
> most of a day scratching our heads until we suddenly realized why the
> header files for our C-like (but with a different actual compiler)
> language weren't being handled properly by GCC's cpp.
> Get an old version of GCC and try it, if you want -- cc will get pasting
> and stringification, but no other user of cpp does, which is because the
> code to do it is not _in_ cpp, AFAICT.
> Thor

Haha!  I've done some more research.

CPP does in fact do the right thing.  cpp does token pasting.

The _PROBLEM_ is that we have a compile command line that tells it to
use traditional cpp:

/import/meteor/tools/SunOS-i386/bin/mipsel--netbsd-gcc -mno-abicalls -x
assembler-with-cpp -traditional-cpp -D_LOCORE -Wa,-fatal-warnings
-Devbmips -I. -I/home/garrett/roofnano/src/sys/contrib/dev/ath/netbsd
-I/home/garrett/roofnano/src/sys/arch -I/home/garrett/roofnano/src/sys
-I/home/garrett/roofnano/src/sys/dist/ipf -c

Note the -traditional-cpp.

So, my question to all you toolchain experts out there is, is this
really necessary?  Can we use an ANSI cpp?  I don't know -- my biggest
concern surrounds some unusual assembler language which requires the use
of # or ##.  The ones I've seen all use $ and % to indicate registers,
etc., but maybe this isn't general?

Note that the special handling of # and ## should not impact things like
comments, because the token pasting/stringification handling only occurs
within a macro definition.

Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
Phone: 951 325-2134  Fax: 951 325-2191