Need help using /usr/lib/cpp for generic text

Randal Schwartz merlyn at iwarp.intel.com
Tue Sep 26 11:47:48 AEST 1989


In article <838 at pacific.mps.ohio-state.edu>, verber at pacific (Mark A. Verber) writes:
[wanting to use cpp for macros and conditionals, and has problems with:]
| (1)  Bloody "# line-number file-name" lines
[example deleted]
| (2)  Leaving <cr> in the text
| 
| When I run text like:	I get the output like:		I would like:
| 
| 	#define foo	before				before
| 	before						test
| 	#ifdef foo	test				after
| 	test
| 	#endif		after
| 	after
| 
| Any suggestions on getting cpp to eat the <cr> at the end of the control
| lines?  Is there a PD cpp or other macro processor that will do the
| job for me... or should I pull out ye old perl manual.

My first inclination would be "yeah, write what you want in Perl",
just because it'd help the sale of my forthcoming book (:-), but
really, cpp is NOT what you want.  Both of your problems are because
cpp output is expected to be fed into the C compiler, and the compiler
wants to keep track of where the source lines were coming from
*before* they were processed.

If you don't want to do it from scratch, how about m4(1)?  You can get
pretty much EXACT control over your input-to-output translation, and
except for the handful of well-defined commands, *nothing* else is
defined.  (Did'ja Ever try to have a variable named "vax" on a vax?  I
did.  Sigh. :-)

Just another Perl hacker,
-- 
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel, Hillsboro, Oregon, USA                           |
| merlyn at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn	         |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/



More information about the Comp.unix.wizards mailing list