This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: cpp problem found by imake
On Wed, May 03, 2000 at 12:11:56AM -0700, Zack Weinberg wrote:
> 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.
xc/config/cf/Imake.tmpl in my copy (have updated it from CVS to make sure it
hasn't been removed):
If TopLevelProject was always X11, this would be easily solveable, but one
can change it (and I think kerberos and similar beasts change it).
BTW: This is not new in XF4.0, it seems to be present e.g. in XF 3.3.6 as
well.
#ifndef TopLevelProject
# define TopLevelProject X11
#endif
#ifndef ProjectRulesFile
# define ProjectRulesFile Concat3(<,TopLevelProject,.rules>)
#endif
#include ProjectRulesFile
#ifndef LocalRulesFile
/* need this to make ANSI-style preprocessors happy */
#define LocalRulesFile <noop.rules>
#endif
#include LocalRulesFile
/*
* get project-specific configuration and rules
*/
#ifndef ProjectTmplFile
#define ProjectTmplFile Concat3(<,TopLevelProject,.tmpl>)
#endif
#include ProjectTmplFile
#ifndef LocalTmplFile
/* need this to make ANSI-style preprocessors happy */
#define LocalTmplFile <noop.rules>
#endif
#include LocalTmplFile
Jakub