cpp problem found by imake

Zack Weinberg zack@wolery.cumb.org
Tue May 2 23:47:00 GMT 2000

On Wed, May 03, 2000 at 08:02:37AM +0200, Jakub Jelinek wrote:
> 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

If you see

test.c:6:16: macro `Concat3' used with just one arg

that is the bug I mentioned earlier, that the special treatment of
<...> extends into macros expanded on an #include line.  But this
won't work even when the bug is fixed; see below.

> #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.

> BTW: What's the reason why
> #define Concat(a,b)a/**/b
> #define Header /usr/include/stdio
> Concat(Header,.h)
> Concat(/usr/include/stdio,.h)
> 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
> Irix)?

Bugs.  -traditional is pretty much untested and I've been rewriting
the macro expander.

Unfortunately I'm having no luck coming up with a test case that can
go in gcc.dg - can you look at this?  I'll do the #include stuff.

> 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)?

We do not and will never support pasting together angle-bracket
includes, in any mode.  Period.  This falls into the category of
undefined preprocessor behavior, and my policy is to make as much of
that as possible generate hard errors.

We _do_ support constructing double-quote includes, using either
the ANSI #arg construct, or the K+R "arg" accidental feature.  I
tested #arg, it works.  I will fix "arg".

I would like to know why X11 feels the need to do this stuff.
Why can't they just

#define Header "/usr/include/stdio.h"

and leave it at that?


More information about the Gcc-bugs mailing list