cpp problem found by imake

Zack Weinberg zack@wolery.cumb.org
Wed May 3 00:12:00 GMT 2000


On Tue, May 02, 2000 at 11:47:33PM -0700, Zack Weinberg wrote:
> On Wed, May 03, 2000 at 08:02:37AM +0200, Jakub Jelinek wrote:
> 
> > #define Header /usr/include/stdio
> > #define MakeHeader(x) "x.h"
> > #define Include MakeHeader(x)
> 			     ^ You meant Header, right?
> > #include Include
> 
> This should work, but it segfaults.  I'll fix that shortly.

Correction: this should not work, and the segfault appears to be due
to unrelated bustage in my work area.

cpplib, cccp (from 2.95), and SunOS 4 cpp all wind up with

#include "Header.h"

from the above example, with 'x' replaced by 'Header' in the #define
Include line.  This is not a surprise: what happened was something
like

 Include -> MakeHeader ( Header )
	 -> " Header .h"	// -traditional, so no extra whitespace...
	 -> "Header.h"		// a string, not subject to further expansion.

I could easily change this, but that wouldn't be the way a "real K+R
preprocessor" behaves.  The conclusion is that there simply is no way
to paste together an include name with -traditional on.

I'm going to have to ask you what X11 is _really_ trying to achieve
here, because this seems utterly perverse, and I'll bet there's a
simpler and more portable way.  I've got XFree 4.0 source lying
around, but I can't find the place where it does this.

zw


More information about the Gcc-bugs mailing list