peter@ficc.ferranti.com (Peter da Silva) (03/14/91)
Better make the indicated changes or watch it barf on a strict ANSI compiler. In article <1991Mar13.001423.5194@Think.COM> dm@think.com (Dave Mankins) writes: ! #ifdef notdef /* > > cc $0 -g -o `basename $0 .c` -Ineeded-includes -lneeded-libraries > ! exit + + */ > > #endif notdef -- Peter da Silva. `-_-' peter@ferranti.com +1 713 274 5180. 'U` "Have you hugged your wolf today?"
ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (03/14/91)
[About the hack for including a command to compile itself in a C program.]
Many years ago Tom Duff wrote a nifty little program called "com";
David Tilbrook added some options, and I later added another.
com [-c$Escape] [-n] [-o | -x] file...
The program searches each file in turn for a comment
/*% <command> \n
where % is the Escape chacter (which defaults to "%"). Any Escape
character occurring in the file is replaced by the file name from the
command line. Then
- if the -o flag appeared, the command is written to stdout, or
- if the -x flag appeared, the command is written to stderr
- if the -n flag did NOT appear, the command is given to system().
So the "com" program itself starts with a comment
/*% cc -o com -O %
*/
In an AWK script, one could have
#/*% awk -f %
When 'make' come around I gradually stopped using 'com'.
> ! #ifdef notdef /*
> > cc $0 -g -o `basename $0 .c` -Ineeded-includes -lneeded-libraries
> ! exit
> + */
> > #endif notdef
If you want to use the "shell-in-C" trick, though, it can be simplified:
#if 0 /*
exec cc -g -o `basename $0 .c` -Ineeded-includes $0 -lneeded-libraries
*/
#endif
--
The purpose of advertising is to destroy the freedom of the market.henry@zoo.toronto.edu (Henry Spencer) (03/15/91)
In article <DQ.90AA@xds13.ferranti.com> peter@ficc.ferranti.com (Peter da Silva) writes: >Better make the indicated changes or watch it barf on a strict ANSI >compiler. > >! #ifdef notdef /* Why? That is legal, strict ANSI C he had inside the #ifdef. In general you can't get away with arbitrary trash in there, but nothing he did was improper. (If you're upset about the $ and `, they are unlawful only when transformed from preprocessor tokens to real tokens, and that never happens in this case.) -- "But this *is* the simplified version | Henry Spencer @ U of Toronto Zoology for the general public." -S. Harris | henry@zoo.toronto.edu utzoo!henry