Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.unix.wizards Subject: Re: Predefined compiler identifiers Message-ID: <1990Aug24.204100.3013@iwarp.intel.com> Date: 24 Aug 90 20:41:00 GMT References: <2423@dsacg3.dsac.dla.mil> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 43 In-Reply-To: nfs1165@dsacg3.dsac.dla.mil ( James L Strickland) In article <2423@dsacg3.dsac.dla.mil>, nfs1165@dsacg3 ( James L Strickland) writes: | Thanks to all of you who sent me mail about how to identify | the predefined variables associated with C compilers. | | The overwhelming consensus is to do "strings /lib/cpp" and | search the output for likely candidates. Put the candidates | into a *.c file and run "cc -E foo.c" to determine the values | for the variables. Here's what does it for me, all at once (no Perl required :-): #!/bin/sh strings -2 /lib/cpp | sort -u | awk '/^[a-zA-Z_][a-zA-Z0-9_]*$/ { print "#ifdef " $0 "\n__" $0 "\n#endif" }' | /lib/cpp | sed -n 's/^__//p' Here's the output on a sun4/490 running SunOS4.1: __BUILTIN_VA_ARG_INCR __FILE__ __LINE__ sparc sun unix And here's the output of the same script on a microvax running (ancient) Ultrix2.3: __FILE__ __LINE__ bsd4_2 ultrix unix vax Just another UNIX hacker, -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/