Article View: gnu.gcc.help
Article #87cpp macro expansion causes problem building X11R5
From: Vince Tessier
Date: Thu, 09 Apr 1992 07:01
Date: Thu, 09 Apr 1992 07:01
62 lines
2594 bytes
2594 bytes
GNU's cpp expands macros, but not in the way that I want. It adds a space after the macro expansion (which is documented in cpp.info, node Output), and this space has caused a problem. I recently built X11R5 for the first time using (mostly) gcc-2.1. X uses cpp's macro expansion facility to "fill-in-the-blanks" for some implementation-dependent items, in particular the directory for xdm's configuration data. cpp left a space in the middle of a path name. The code that produces xdm-config is in ./mit/clients/xdm/config/Makefile: xdm-config:: xdm-conf.cpp $(RM) $@ $(CPP) -DXDMDIR=$(XDMDIR) <xdm-conf.cpp | sed -e '/^# *[0-9][0-9]* *.*$$/d' -e '/^XCOMM$$/s//#/' -e '/^XCOMM[^a-zA-Z0-9_]/s/^XCOMM/#/' >$@ where XDMDIR has been defined as something like `/usr/X11R5/lib/X11/xdm'. Here's a simpler example that shows the effect: Put the following in Makefile: CPP = /usr/gnu/lib/gcc-lib/sparc-sunos4.1.1/2.1/cpp # CPP = /usr/lib/cpp xdm-config:: xdm-conf.cpp rm -f $@ $(CPP) -DXDMDIR=floob <xdm-conf.cpp >$@ And here's a piece of xdm-conf.cpp: DisplayManager.errorLogFile: XDMDIR/xdm-errors DisplayManager.pidFile: XDMDIR/xdm-pid DisplayManager.keyFile: XDMDIR/xdm-keys Invoking make with Makefile as above, the results are: # 1 "" DisplayManager.errorLogFile: floob /xdm-errors DisplayManager.pidFile: floob /xdm-pid DisplayManager.keyFile: floob /xdm-keys With the other CPP line enabled, the results are: # 1 "" DisplayManager.errorLogFile: floob/xdm-errors DisplayManager.pidFile: floob/xdm-pid DisplayManager.keyFile: floob/xdm-keys The first output line is the result of skipping the sed script. I ran this on a SPARC 4/60 w/ SunOS 4.1.1, and also tried it on a VAX runing ULTRIX 4.1 with the same results: GNU cpp added a space, and the native system cpp gave the results I wanted. Is there any (convenient) way to change GNU cpp's action of adding a space after macro expansion? -- Vince -- Vince Tessier Dairyland Fertilizer & Supply vtessier@vela.acs.oakland.edu "Purveyors of Bullshit to the Trade"
Technical Details
Message-ID:
<14634@vela.acs.oakland.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!agate!usenet.ins.cwru.edu!wsu-cs!vela!vtessierShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!agate!usenet.ins.cwru.edu!wsu-cs!vela!vtessier From: vtessier@vela.acs.oakland.edu (Vince Tessier) Newsgroups: gnu.gcc.help Subject: cpp macro expansion causes problem building X11R5 Summary: cpp added space in middle of pathname Keywords: cpp macro X Message-ID: <14634@vela.acs.oakland.edu> Date: 9 Apr 92 07:01:12 GMT Article-I.D.: vela.14634 Organization: Oakland University, Rochester MI. Lines: 62