cpp problem found by imake

Jakub Jelinek jakub@redhat.com
Tue May 2 22:57:00 GMT 2000

On Tue, May 02, 2000 at 09:05:36AM -0700, Zack Weinberg wrote:
> On Tue, May 02, 2000 at 06:02:58PM +0200, Jakub Jelinek wrote:
> > Hi!
> > 
> > Current cpp does not also like the following snippet
> > (distilled from XF4.0 cf/ stuff):
> > 
> > #define Concat3(a,b,c) a##b##c
> > #define Header /usr/include/stdio
> > #define Include Concat3(<,Header,.h>)
> > #include Include
> This came up before.  It's undefined behavior - token paste produces
> an illegal token.  They should do something like
> #define Header /usr/include/stdio
> #define HNAME(x) _HNAME(x.h)
> #define _HNAME(x) #x
> #define Include HNAME(Header)
> #include Include
> Note that the HP/UX and Irix cc are reported to reject this construct too.
> [I know there is a bug in that the special treatment of <...> extends
> to macros expanded on the #include line, but this particular example
> is still undefiend behavior.]

Ok, fine for ANSI cpp, what about traditional:

#define Concat3(a,b,c)a/**/b/**/c
#define Header /usr/include/stdio
#define Include Concat3(<,Header,.h>)
#include Include

does not work, neither does

#define Header /usr/include/stdio
#define MakeHeader(x) "x.h"
#define Include MakeHeader(x)
#include Include

nor anything else I've tried. Can you please tell me what might do the job
in traditional (best what would work with both old cccp and cpp)?

BTW: What's the reason why

#define Concat(a,b)a/**/b
#define Header /usr/include/stdio

produces different output in cpp -traditional to old cccp -traditional
(which has identical output to /usr/ccs/lib/cpp in Solaris and /lib/cpp in
cpp puts an additional space at the beginning of each line and a space
between stdio and .h on the first line.


More information about the Gcc-bugs mailing list