Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!snorkelwacker!apple!oliveb!orc!mipos3!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.c Subject: Re: where to find all those #ifdef's and #defines Message-ID: <1990Jan9.174739.8828@iwarp.intel.com> Date: 9 Jan 90 17:47:39 GMT References: <40059@ames.arc.nasa.gov> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Hillsboro, Oregon, USA Lines: 34 In-Reply-To: dwhitney@pioneer.arc.nasa.gov (David Whitney- RCD) In article <40059@ames.arc.nasa.gov>, dwhitney@pioneer (David Whitney- RCD) writes: | I've got a lot of programs that run on different systems and I want to find | out where each is running (among other things). I've seen a lot of | cpp commands to determine some things (e.g. | | #ifdef CRAY | ...do such and such | #endif | | Where is "CRAY" defined? Or "unix" or "sgi", etc.? | | Does anyone know who, what, or where to find these definitions for each | machine? What I'd like (ideally) is a list of the variables that | are #define'ed at any one time. Thanks, Here it is (and it's not even in Perl :-)... #!/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' This presumes that you have access to your cpp as '/lib/cpp'. This is true for (nearly?) all of the unicies that I've played with, but beware. It also presumes you have a BSD-like 'strings' command. Just another longtime C hacker, -- /== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\ | on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn | \== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/