This is not guaranteed to work since the characters after 'has_include('
have special lexing rules that can't possibly be applied when
has_include is generated by a macro. It also breaks the crash reproducers
generated by -frewrite-includes (see https://llvm.org/pr37990).
Details
Diff Detail
- Repository
- rCXX libc++
- Build Status
Buildable 20141 Build 20141: arc lint + arc unit
Event Timeline
Where are the special lexing rules specified?
include/__config | ||
---|---|---|
153 | I do prefer not hijacking this name, but if it's needed to make things work, then it's OK with me. @mclow.lists Are you OK if we steal this identifier and #define it ourselves. |
Looks like the special rules are explained in 3.2.2 of https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#recs.hasinc
In the first form of the has-include-expression, the parenthesized header-name token is not subject to macro expansion. The second and third forms are considered only if the first form does not match, and the preprocessing tokens are processed just as in normal text.
While there is no mention of the define to 0 if not present for __has_include it is used in the example for __has_cpp_attribute in https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#recs.hasattr.
include/__config | ||
---|---|---|
153 | This is the correct way of dealing with missing __has_include() according to @rsmith |
include/__config | ||
---|---|---|
153 | If you would prefer to not define this name yourself, the other option would be to replace all uses of __has_include(blah) with #ifdef __has_include #if __has_include(blah) //... #endif #endif | |
1062–1075 | Example: #if defined(__MINGW32__) && defined(__has_include) #if __has_include(<pthread.h>) #define _LIBCPP_MINGW32_HAS_PTHREAD #endif #endif #if defined(__FreeBSD__) || \ // [...] defined(__sun__) || \ defined(_LIBCPP_MINGW32_HAS_PTHREAD) |
I do prefer not hijacking this name, but if it's needed to make things work, then it's OK with me.
@mclow.lists Are you OK if we steal this identifier and #define it ourselves.