How can I find out cc or cpp symbols?

Dave Collier-Brown dave at lethe.UUCP
Wed May 3 12:27:33 AEST 1989


In article <1954 at trantor.harris-atd.com> bbadger at x102c.harris-atd.com (Bernie Badger Jr.) writes:
>Is there a way to find out what macros are defined?  It's particularly hard 
| to predict which names will be _predefined_.

In article <1938 at csuna.csun.edu> abcscnge at csuna.csun.edu (Scott Neugroschl) writes:
| I am also interested in finding out about what are the "manifest defines" of
| a CC implementation.  I write code for 5 different platforms, and would
| like it to be semi-portable ...

  Well, its formally impossible to predict what names will (eventually) be
predefined.  So I recommend approaching the problem from a different 
direction.

  What you want to know is whether or not a certain capability is present, and
if so how to access it.  Saying "#ifdef 4.2BSD" is far too coarse for most
typical problems.
  So I depend on a bug (!).

  C compilers used to depend on sequences of #ifdefs to ensure that
the contents of system .h files were not inadvertently redefined by
including the containing files more than once.  Even ANSI C requires this
to protect typedefs (the macro bug got fixed: see aother discussuion in
this same forum).
  So when I'm about to call something whose interface might change (or
be absent!), I grep the man page for #include strings and pop up the
relevant .h file in another window/another editor.  This usually contains
something like

#ifndef _BSD_PECULIAR_SHMOPS
#define  _BSD_PECULIAR_SHMOPS
typedef struct shmop_t {
	...
} SHMOP;
SHMOP *shmooze(struct time_t howlong);
...

so I can can just copy the definition of shmooze() into the code I'm
writing, along with the #ifndef, which gets its "n" deleted. And away we go.

Of course, half the time I have to AMEND the #include files, but thats'
another story... (:-{).

-dave
  
-- 
David Collier-Brown,  | {toronto area...}lethe!dave
72 Abitibi Ave.,      |  Joyce C-B:
Willowdale, Ontario,  |     He's so smart he's dumb.
CANADA. 223-8968      |



More information about the Comp.std.c mailing list