On Fri, 15 Nov 2013, Richard Biener wrote: > Yeah, though this has interesting effects on includes that do stuff like > > #ifdef NO_DOLLARS_IN_LABELS > ... > > where the presence of this definition depends on another header file > and thus the ultimate outcome in your .c file depends on include file > order. > > So ... no #ifdefs inside headers? Or have meta-defines like > > #define NO_DOLLARS_IN_LABELS_DEFINED > > and > > #ifndef NO_DOLLARS_IN_LABELS_DEFINED > #error ... > #endif > > at use sites?
Rather than such a meta-define, I prefer changing the semantics of the macro itself from defined/undefined to nonzero/zero, changing the users from #if to if () conditionals (or ? :, as appropriate), and adding a default zero definition to defaults.h along with updating all definitions, users and documentation. A meta-define seems just as error-prone as the original #ifdef. Similarly, for any macros with default definitions scattered around the source tree rather than in defaults.h, moving them to defaults.h is a good idea. Probably I should adapt my target-macro-listing scripts to list target macros used in #if/#ifdef/#ifndef/#elif, outside of defaults.h, so we can see how big this part of the problem is. -- Joseph S. Myers jos...@codesourcery.com