Predefined compiler identifiers
Randal Schwartz
merlyn at iwarp.intel.com
Sat Aug 25 06:41:00 AEST 1990
In article <2423 at dsacg3.dsac.dla.mil>, nfs1165 at dsacg3 ( James L Strickland) writes:
| Thanks to all of you who sent me mail about how to identify
| the predefined variables associated with C compilers.
|
| The overwhelming consensus is to do "strings /lib/cpp" and
| search the output for likely candidates. Put the candidates
| into a *.c file and run "cc -E foo.c" to determine the values
| for the variables.
Here's what does it for me, all at once (no Perl required :-):
#!/bin/sh
strings -2 /lib/cpp |
sort -u |
awk '/^[a-zA-Z_][a-zA-Z0-9_]*$/ { print "#ifdef " $0 "\n__" $0 "\n#endif" }' |
/lib/cpp |
sed -n 's/^__//p'
Here's the output on a sun4/490 running SunOS4.1:
__BUILTIN_VA_ARG_INCR
__FILE__
__LINE__
sparc
sun
unix
And here's the output of the same script on a microvax running
(ancient) Ultrix2.3:
__FILE__
__LINE__
bsd4_2
ultrix
unix
vax
Just another UNIX hacker,
--
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III |
| merlyn at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
More information about the Comp.unix.wizards
mailing list