Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpcuhb!hpcllla!hpcllca!curtw From: curtw@hpcllca.HP.COM (Curt Wohlgemuth) Newsgroups: comp.std.c Subject: Re: How can I find out cc or cpp symbols? Message-ID: <16490012@hpcllca.HP.COM> Date: 28 Apr 89 20:44:13 GMT References: <1954@trantor.harris-atd.com> Organization: Hewlett Packard Calif. Language Lab Lines: 40 > Is there a way to find out what macros are defined? It's particularly hard > to predict which names will be _predefined_. You may want to try this script. I got the basic sed part from a friend who got it off of some notes group or other. I changed it because we have a cpp which does not act as a filter; it needs an input file. Here it is: ------------------------------------------------------------- #! /bin/ksh SELF=`basename $0` PATH=:/bin:/usr/bin:/usr/local/bin TEMP=/tmp/t$$ OUTFILE=/tmp/out$$ trap "rm -f $TEMP $OUTFILE" 0 1 2 if [ $# -lt 1 ]; then echo "usage: $SELF [ options ]" exit 1 fi CPP=$1 shift OPTIONS="$*" strings -a -2 $CPP | sed '/^a-zA-Z0-9_/!s/.*/#ifdef &\ "%&"\ #endif/p' > $TEMP $CPP $OPTIONS $TEMP > $OUTFILE 2> /dev/null sed -n '/%/s/[%"]//gp' $OUTFILE | sort | uniq rm -f $TEMP $OUTFILE exit 0