Search code examples
genericskeywordc-preprocessorlanguage-featuresc11

How to determine if C11 _Generic is supported by the compiler using preprocessor directives?


I would like to know if there is any way to determine if support for _Generic type-generic macros can be determined for a given compiler using preprocessor directives such as:

#if __C11_GENERIC_IS_SUPPORTED__ == 1

Any help would be appreciated...


Solution

  • _Generic is not an optional feature, so there is no feature test macro. Normally you'd just have to check for the C version that your compiler claims to implement.