dwhitney@pioneer.arc.nasa.gov (David Whitney- RCD) (01/09/90)
No seemed to know before, but I'm sure somone's _gotta_ know somewhere: 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, -Dave (please e-mail responses)
merlyn@iwarp.intel.com (Randal Schwartz) (01/10/90)
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!" ==/
scott@memex.co.uk (Scott Williamson) (01/11/90)
In article <1990Jan9.174739.8828@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: >In article <40059@ames.arc.nasa.gov>, dwhitney@pioneer (David Whitney- RCD) writes: >| >| 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 > > Shell script removed This will not work in all cases. In Gould's UTX/32 (4.3bsd based), some defines are hard-coded in /lib/cpp (eg. gould, unix etc.) but others are passed on the command line used by /bin/cc when it calls cpp (eg. -Dselport, -DCOFF). Other systems may have the same problem. The shell script should probably be modified to look for '-DXXX' in /bin/cc also. Scott Williamson scott@memex.co.uk