Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!think!paperboy!osf!dbrooks From: dbrooks@osf.osf.org (David Brooks) Newsgroups: comp.lang.c Subject: Re: SUMMARY: C Compiler Predefined Manifest Definitions Message-ID: <12313@paperboy.OSF.ORG> Date: 22 Aug 90 03:38:50 GMT References: <185@n4hgf.Mt-Park.GA.US> <191@n4hgf.Mt-Park.GA.US> Sender: news@OSF.ORG Reply-To: dbrooks@osf.org (David Brooks) Organization: Open Software Foundation Lines: 61 In article <191@n4hgf.Mt-Park.GA.US> wht@n4hgf.Mt-Park.GA.US (Warren Tucker) writes: >In article <185@n4hgf.Mt-Park.GA.US> I wrote: >> I would like to compile a list of pre-defined manifest constants >> supplied by various C compilers. Contributors might want to use this shell script, which I extended from one I saw a while back; sorry, I forgot the original author. It finds all the strings stored in cc and cpp that are defined during a normal "cc" command. It won't find anything that's pieced together at runtime. ----8<-------- #!/bin/sh # Change these if appropriate: 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 | sed '/^-D.*/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 ----8<-------- Using this, cc on a DECstation gives: LANGUAGE_C MIPSEL __FILE__ __LINE__ bsd4_2 host_mips mips ultrix unix and on a VAX/Ultrix: __FILE__ __LINE__ bsd4_2 ultrix unix vax Get well soon, Warren. -- David Brooks dbrooks@osf.org Systems Engineering, OSF uunet!osf.org!dbrooks