This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Feature request - a macro defined for GCC


On Jul 3, 2008, at 2:12 PM, Josh Triplett wrote:
I'd suggest defining exactly one new preprocessor symbol, to advertise
the support for the feature-testing mechanism.  For instance,
__HAVE_EXTENSION_SUPPORTED__, or __FEATURE_SUPPORTED_SUPPORTED__. :)
The rest could use syntax like you suggest above.  For instance:


Sure. The idea was that you'd do something like:

#ifndef __FEATURE_SUPPORTED_SUPPORTED__  /* or whatever :) */
#define has_extension(x) 0
#else
#define has_extension(x) __has_extension__(x)
#endif

which allows you to use "#if has_extension(typeof)" in your code portably.

In fact, it would be easy to make __has_extension__ actually be a macro itself, allowing one to say:

#ifdef __has_extension__
...

which is even more clear.

The only problem then becomes maintaining the canonical list of
extension names. We could use the ugly approach of names like
"org.gnu.gcc.extension.sentinel" and "org.kernel.sparse.address_space",
but that seems entirely too ugly. The other alternative seems like a
central registry of extension names; I'd happily help maintain such a
registry.

I have no opinion on an approach, but I agree that it would be good to have a centralized list. I would definitely add support for this to Clang.


-Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]