__ has_include() macro implementation can be accepted in GCC?

Georg-Johann Lay gjl@gcc.gnu.org
Sun Sep 9 12:12:00 GMT 2012


Bryan Hundven schrieb:
> niXman wrote:
>>
>> __has_include() [1] macro implementation can be accepted in GCC(may be
>> as GCC extension)?
>> Is there any sense to send a patch?
>>
>> [1] http://clang.llvm.org/docs/LanguageExtensions.html#__has_include
> 
> I would also be interested in an answer to see if this can become a
> part of gcc (as well as the has_warning)

Also interesting in the __has_builtin.

In the avr backend I added built-in defines for each target-specific
built-in function and built-in type:

    "For each built-in function for AVR, there is an equally named,
     uppercase built-in macro defined. That way users can easily query
     if or if not a specific built-in is implemented or not.
     For example, if __builtin_avr_nop is available the macro
     __BUILTIN_AVR_NOP is defined to 1 and undefined otherwise."

I think it is much more convenient and and consistent across
architectures to have something like __has_builtin or have the
builtin machinery define such macros in a consistent nomenclature.

> but you could just check the  defines a header usually makes:
> 
> std_header.h:
> #ifndef STD_HEADER_H
> #define STD_HEADER_H

This used internal knowledge of the header, some use naming
convention like STD_HEADER_H_ or STD_HEADER_H__.



More information about the Gcc-help mailing list