[cfe-dev] Possible bug with __has_cpp_attribute
Kal
b17c0de at gmail.com
Wed May 6 02:28:22 PDT 2015
Hi,
The following seems like a clang bug.
You can't use __has_cpp_attribute with namespaces in a header that is
included from C. For example:
#if __has_cpp_attribute(clang::fallthrough)
...
#endif
Yields:
error: builtin feature check macro requires a parenthesized identifier.
Shouldn't __has_cpp_attribute() evaluate to 0 for C programs?
I worked around the issue with something like:
#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) 0
#elif defined(__clang__) && !defined(__cplusplus)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wbuiltin-macro-redefined"
#define __has_cpp_attribute(x) 0
#pragma clang diagnostic pop
#endif
Is there a better way?
-Kal
More information about the cfe-dev
mailing list