Article 3396 of alt.sources: Path: cos!uunet!uunet!spool.mu.edu!agate!eos!data.nas.nasa.gov!amelia!roelofs From: roelofs@nas.nasa.gov (Greg R. Roelofs) Newsgroups: alt.sources,comp.sys.sgi Subject: predefined macros: alternate approach Summary: C (meta-)program to create C program to check for macros Message-ID: <1991Jul19.013335.11081@nas.nasa.gov> Date: 19 Jul 91 01:33:35 GMT References: Sender: news@nas.nasa.gov Followup-To: alt.sources.d Organization: University of Chicago Lines: 1071 Xref: cos alt.sources:3396 comp.sys.sgi:11036 Randal Schwartz/Robert Skinner/Skip Montanaro's script to search for predefined macros is excruciatingly elegant (I wish *I* had thought of it), but it only works under Unix. I wrote a brute-force C program to do the same sort of thing a couple months ago--"brute-force" because it has a database of possible tokens which must be maintained by hand-- but it has the additional benefits of working under most operating systems, of checking (only real BSD systems and the NeXT seem to define anything in there), and particularly of printing out the value of the token in question. It's also a legitimate use for a meta- program: with some 580+ possible macros, the created program is nearly 200k long, as opposed to only 18k for the meta-program. Here's some sample output: This information is from defind.c, version 3, of 3 June 1991. The following tokens are predefined by the preprocessor/compiler for 386 PC, MS-DOS, Microsoft C 6.00: M_I8086 (1) M_I86 (1) M_I86SM (1) _MSC_VER (600) MSDOS (1) __TIMESTAMP__ (Tue Jun 04 12:19:13 1991) Additionally, the following standard tokens are defined: __FILE__ (defind.c) __LINE__ (5506) __DATE__ (Jun 04 1991) __TIME__ (12:20:06) There are a few more examples in the archive itself. Anyone interested in the information I've collected to date is welcome to it (please make sure you can handle a uuencoded zipfile, because I'm not going to have time to send it in other formats). Likewise, anyone who runs the program (or the original shell script) and is willing to send me the results is more than welcome to do *that*. Please be sure to describe the machine, OS, and C compiler in reasonable detail! And if you have an Amiga or Mac or CP/M machine or IBM VM/CMS mainframe or PC running an oddball compiler or anything else whose C compiler manual lists predefined macros which aren't in tokens.h, *please* send that information to me. Even- tually this information will make its way back into zip, unzip and other programs, and that helps reduce Makefile complexity. Btw, Mark Adler of Info-ZIP fame contributed some valuable suggestions. Also, follow-ups are directed to alt.sources.d, since this has little to do with SGI stuff. Greg