🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
2 messages
2 total messages Started by Ernest Prabhakar Thu, 20 Aug 1992 23:53
Can C preprocessor handle #include "fooa" "foob"
#1251
Author: Ernest Prabhakar
Date: Thu, 20 Aug 1992 23:53
20 lines
1438 bytes
There is a funky trick which works under the 3.0 NeXT preprocessor, but not  
under GNU 2.1 or 2.2.  It is:
#include "string1" "string2"
which resolves to:
#inclue "string1string2"
Which is then referenced for the include file.

Now, I'm not savvy enough to understand exactly what the ANSI C preprocessor is  
supposed to guarantee.  Does stringification take place before includes?  Then  
GNU is broken.  Is it the other way around?  Then NeXT's preprocessor supplies  
(and thus NeXT include files rely upon) non-standard behavior.  Could someone
perhaps shed some light on this for me?

- Ernie P.
--
Ernest N. Prabhakar                  Caltech High Energy Physics
Member, League for Programming Freedom (league@prep.ai.mit.edu)
CaJUN President        NeXTMail:ernest@pundit.cithep.caltech.edu
"...and ourselves, your servants for Jesus sake." - II Cor 4:5b
#import <std/disclaimer.h>
Re: Can C preprocessor handle #include "fooa" "foob"
#1260
Author: Jutta Degener
Date: Fri, 21 Aug 1992 14:54
26 lines
1394 bytes
ernest@pundit.cithep.caltech.edu (Ernest Prabhakar) writes:
> There is a funky trick which works under the 3.0 NeXT preprocessor, but not  
> under GNU 2.1 or 2.2.  It is:
> #include "string1" "string2"
[..]
> Does stringification take place before includes?  Then GNU is broken.
> Is it the other way around?  Then NeXT's preprocessor supplies (and
> thus NeXT include files rely upon) non-standard behavior.

GNU's right, this trick is just too funky for ANSI C.

String concatenation takes place in translation phase 6, when
the inclusions (which are done in phase 4) have long since
happened.

The ANSI thing to do would be to glue identifiers, not strings,
and stringize them afterwards:

	#define	stringize(a)		#a
	#define	glue(base, version)	stringize(base ## version)

	#include glue(fish, 2.1.1.2)

Followups to comp.lang.c.

-Jutta
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads