Path: utzoo!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!paperboy!osf.org!dbrooks From: dbrooks@osf.org (David Brooks) Newsgroups: comp.lang.c Subject: Re: Finding out what is defined Keywords: #define vax sun i386 Message-ID: <20114@paperboy.OSF.ORG> Date: 18 Mar 91 17:56:00 GMT References: <1991Mar18.045748.6860@javelin.es.com> Sender: news@OSF.ORG Distribution: usa Organization: Open Software Foundation Lines: 34 In article <1991Mar18.045748.6860@javelin.es.com>, jwilliam@javelin.es.com (Jerry Williams) writes: |> I would like to find out what is defined for a given compiler. I saw a clever solution on the net a while back; unfortunately I lost the author. Also, I added a few features. -----------------------cut #!/bin/sh # Change these as needed CC=/bin/cc CPP=/lib/cpp tfile1=/tmp/stra$$ tfile2=/tmp/strb$$.c # My "strings" will read stdin, but the manpage doesn't guarantee that. cat $CC $CPP > $tfile1 strings -a -2 $tfile1 | tr ' ' '\012' | sed 's/^-D//' | sort -u | awk '/^[a-zA-Z_][a-zA-Z0-9_]*$/ { printf "#ifdef %s\nZ__Z%s\n#endif\n", $0, $0 }' > $tfile2 $CC -E $tfile2 | sed -n 's/^Z__Z//p' | pr -i -t /bin/rm $tfile1 $tfile2 exit -- David Brooks dbrooks@osf.org Systems Engineering, OSF uunet!osf.org!dbrooks "It's not easy, but it is simple."