[comp.lang.c] where to find all those #ifdef's and #defines. Summary

dwhitney@pioneer.arc.nasa.gov (David Whitney- RCD) (01/10/90)

First off, thanks to all who replied, you were all very helpful.  The
summary of all responses to the "where does one look to find all
values previously "#defined" is as follows:

cpp: The C preprocessor defines a certain amount of hardware/OS
definitions that are either listed in the documentation for one's
particular compiler or in "man cpp" under the description of the -U
option.  (e.g. "unix" "lint" "sun" "sgi" "vax" ....) 

Randal Schwartz (merlyn@iwarp.intel.com) contributes this incredibly
useful bit of hacking that lists all cpp #defines:

#!/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'

     Also the -D option to cc can specify more #defined values to pass
to a program.  Unfortunately there is no way to find these unless they
are in the Makefile.  (e.g. cc -D DEBUG foo.c)

makefiles:  The makefile for a particular program sometimes has these
-D options listed.

header files: Most local #defines are in the header (#include foo.h)
files for a particular program.  (e.g.  _XLIB_H_, macros, MAXFOO,
MINFOO, NULL, etc.)  There could conceivably be many many of these
nested #includes within #include files.  "Xlib.h", for example,
includes "X.h" and <sys/types.h> as well.  (whether you like it or
not).  Much recursive searching is required to find all of these.

Again, thanks to all whose input makes up this post, and I hope this
helps any others in need.



_____________
David Whitney
whitney@athena.arc.nasa.gov