Re: The inclusion of <string> makes the word `minor' special (g++)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sergey,

>Why would the macros from <sys/sysmacros.h> come up after
the inclusion of <string>?

I suspect because there is a dependency on <sys/sysmacros.h> from <string>, probably through <cstring> or some other lower level header file.

>I'd think they would be #undef'ed somewhere in the C++ include files that include the <sys/sysmacros.h>.

Why? Each header file is responsible for it's own identifiers; it's not responsible for second guessing all the identifiers that may-or-may-not have been defined or declared by other header files.

>If anywhere at all, they could be accessible from the <c*> include files (if they are covered by the C standard).

System header files are not covered by the C standard.

>I can already see a large list at the top of every sourcefile :) :

I despise the C preprocessor.

I wish that if a programmer wanted to use a preprocessor directive, it'd be explicit, you'd have to do something like this:

#define VALUE 3
int i = VALUE#;

But alas, it's far too late for that to happen.

>And this only if the compiler is g++ 3.x, and #undef'ing an undefined macro isn't polite, so I'd wrap it all in a big ugly #ifdef or a lot of smaller but nevertheless ugly #ifdefs.

As far as I am aware, It's not impolite to #undef an identifier that has not been defined.

>Isn't there another solution?

Write a little program that pulls out every single identifier in your code and makes a paranoia file "foo.paranoia":
#define return return
#define class class
#define minor minor
#define i i


Then do this at the bottom of your source file:
#include "foo.paranoia"

That will help you discover any identifier collisions with macros.

BTW:  I have seen a #define return macro.  That took days to figure out.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux