Checksum: 04026 Lines: 36 Path: utzoo!sq!ian From: ian@sq.com (Ian F. Darwin) Date: Wed, 3-May-89 17:17:10 EDT Message-ID: <1989May3.171710.22035@sq.com> Newsgroups: comp.std.c Subject: Re: How can I find out cc or cpp symbols? References: <1954@trantor.harris-atd.com> <16490012@hpcllca.HP.COM> Reply-To: ian@sq.com (Ian F. Darwin) Organization: SoftQuad Inc., Toronto > > Is there a way to find out what macros are defined? It's particularly hard > > to predict which names will be _predefined_. > > You may want to try this script. I got the basic sed part from a friend > who got it off of some notes group or other. I changed it because we > have a cpp which does not act as a filter; it needs an input file. The script posted is a valiant attempt, but it's doomed to failure because it contains some unstated and unfortunate assumptions about the private internal data structure of C preprocessors. (I'm ignoring the fact that it uses "strings", which is only standard in BSD systems; it is at least possible to write a "strings" command for any given a.out format, and there are versions kicking around for COFF and some other formats). You cannot validly make the assumption that all C preprocessors will store each predefined string as a separate "strings"-able entity. One cpp might predefine them all as one giant string; another might encode them somehow; another might have them in the "cc" command rather than in cpp. The SVID and probably other standards have long advocated that "the recommended way to invoke cpp is through the cc command"; pANS doesn't even require that cpp be implemented as a separate program. For a chuckle, try running it on gcc's cpp. The posted version of the script first fails because it sets the path to exclude /usr/ucb, where "strings" is on our system. When you fix this, it gets a syntax error (at least on this system, a Sun 3 running SunOS 3.x). To answer the original question, "to find out what macros are defined", read the compiler's documentation. If the predefined macros aren't documented, complain to your vendor. If that doesn't help, buy from a different vendor next time, and let the losers (and maybe the appropriate newsgroups/mailing lists) know why. Ian F. Darwin, SoftQuad Inc., Toronto, utzoo!sq!ian, ian@sq.com