where to find all those #ifdef's and #defines
Randal Schwartz
merlyn at iwarp.intel.com
Wed Jan 10 04:47:39 AEST 1990
In article <40059 at ames.arc.nasa.gov>, dwhitney at pioneer (David Whitney- RCD) writes:
| I've got a lot of programs that run on different systems and I want to find
| out where each is running (among other things). I've seen a lot of
| cpp commands to determine some things (e.g.
|
| #ifdef CRAY
| ...do such and such
| #endif
|
| Where is "CRAY" defined? Or "unix" or "sgi", etc.?
|
| Does anyone know who, what, or where to find these definitions for each
| machine? What I'd like (ideally) is a list of the variables that
| are #define'ed at any one time. Thanks,
Here it is (and it's not even in Perl :-)...
#!/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'
This presumes that you have access to your cpp as '/lib/cpp'. This is
true for (nearly?) all of the unicies that I've played with, but
beware. It also presumes you have a BSD-like 'strings' command.
Just another longtime C hacker,
--
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III |
| 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.lang.c
mailing list