[comp.lang.c] macro and variable name collisions

kyle@xanth.UUCP (03/25/87)

In article <7700002@iaoobelix.UUCP>, wagner@iaoobelix.UUCP writes:
> 
> I have tried to run `screen' on a Sun. Well, the file screen.c contains a
> variable called `sun'...
> 
> You know what happened: `sun' gets replaced by `1' because we're running on a
> Sun and cpp wants to indicate this!!

I had a similar problem trying to make a sendmail header file with a

#define DBM 1

in it, live with 4.3 BSD's ndbm.h, in which DBM is struct typedef!  I had a
devil of a time trying to figure out what was going on.  It would be nice if
cpp would allow programmers to write something like

#define DBM DBM

Anyone know of a better way to avoid such collisions, besides say, prepending
an _ to macros #define'd that will only be used in later #ifdef's?

kyle jones <kyle@xanth.cs.odu.edu>
odu computer science, norfolk, va