🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5968

Re: How can I find out cc or cpp symbols?

#5968
From: Curt Wohlgemuth
Date: Fri, 28 Apr 1989 20:44
40 lines
1343 bytes
> 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 <cpp> [ 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
Technical Details
Message-ID: <16490012@hpcllca.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpcuhb!hpcllla!hpcllca!curtw
References: <1954@trantor.harris-atd.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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