On Jul 3, 2008, at 10:01 AM, Andrew Haley wrote:

Chris Lattner wrote:

IMO, the whole notion of a compiler-specific macro has pretty limited
usefulness. Why not add macros for specific *features* offered by the
compiler.  For example:

#ifdef __SUPPORTS_NESTED_FUNCTIONS__

is much better than some mismash of version checking, which isn't
guaranteed to be right in the future.

Yeah, but in the absence of an external specification of the syntax it'd
have to be __SUPPORTS_GNU_NESTED_FUNCTIONS__.

The feature names should be independent of the set of compilers that happen to implement them, that's the whole point. Consider:

#ifdef __SUPPORTS_GNU_CXX_MIN_MAX_OPERATORS__

Mainline GCC doesn't support "GNU" min max operators! GCC adds and removes extensions, and other compilers have good support for subsets of the GCC extensions. Obviously if Intel is defining __GNUC__ with moderate success, then they implement whatever extensions the macro is guarding.

Hmm, looks like this could
get very messy, very quickly; I don't think you could do this in any
effective way without some compiler-independent organization to define
these macros.

Huh?  Why not?

-Chris

Reply via email to