If you have a canonical #ifndef wrapper in a header file, e.g.: #ifndef FOO_H__ ... #endif clang and GCC will avoid re-including the header if FOO_H__ is defined. But for this to work the #ifndef wrapper must have the above form (|#if defined(FOO_H__)| is also allowed, and there can't be any tokens before or afterwards (but whitespace and comments are ok). (See http://gcc.gnu.org/onlinedocs/cpp/Once_002dOnly-Headers.html#Once_002dOnly-Headers and http://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html for details.) SpiderMonkey has numerous header files that violate this, and so get multiply-included unnecessarily.
Driveby comment, but if we're going to do this (I'm certainly not opposed!), we should use include guards don't violate C++ naming rules. Most particularly they shouldn't start with "_", and they shouldn't include sequential underscores. A whole bunch of our existing include guards violate these rules right now, because copypasta for one, and because who ever has time to clean up that sort of junk? It might also be worth standardizing include-guard naming at the same time. I have no feelings on the format, except that it seems worth poking the Gecko people to pick one scheme that everyone, everywhere, could use.
Dup'ing; this got double-filed due to a bzexport snafu on my end.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 881579
You need to log in before you can comment on or make changes to this bug.