home *** CD-ROM | disk | FTP | other *** search
- From: montnaro@spyder.crd.ge.com (Skip Montanaro)
- Newsgroups: comp.sys.sgi,alt.sources
- Subject: predefined macros
- Message-ID: <MONTNARO.91Jul15091019@spyder.crd.ge.com>
- Date: 15 Jul 91 13:10:19 GMT
-
-
- Robert Skinner posted a short script to comp.sys.sgi last week that prints
- the predefined macros for the C compiler. I modified it to clean up after
- itself, pick up defines generated with -D, and work on a number of other
- machines. I don't know who the original author is (Robert picked it up from
- the net as well), but s/he deserves credit for a clever idea. Here 'tis.
-
- ----------cut----------
- #!/bin/sh
-
- # what-defs: prints names of predefined cpp macros
- # tested on Sun3, Sun4, SGI, HP, Stellar, Convex, DECstation, Moto 1147
-
- # stupid, stupid Ultrix! I have a "which" function that I cannot use, because
- # the Ultrix /bin/sh does not understand shell functions! (try /bin/sh5!)
- # also, the Ultrix "test" command does not understand the -x flag!
-
- path="`echo $PATH | sed -e 's/:/ /g'`"
- cc=`for dir in $path ; do
- if [ -r $dir/cc ] ; then
- echo $dir/cc
- exit
- fi
- done`
-
- strings -a -2 /lib/cpp $cc |
- sed -e 's/^-D//' |
- sort -u |
- sed -n '/^[a-zA-Z_][a-zA-Z0-9_]*$/s//#ifdef &\
- "%&"\
- #endif/p' >/tmp/$$.c
-
- cc -E /tmp/$$.c |
- sed -n '/%/s/[%"]//gp'
-
- rm -f /tmp/$$.c
- ----------cut----------
-
- --
- Skip (montanaro@crdgw1.ge.com)
-