Author: Chris Lattner Date: To: Josh Triplett CC: Jim Wilson, x z, gcc, linux-sparse Subject: 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:
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.