Bug 23616 – ImportC: clang __has_feature and __has_extension not recognized

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-01-09T22:30:26Z
Last change time
2023-01-10T18:31:06Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=23613

Comments

Comment #0 by bugzilla — 2023-01-09T22:30:26Z
https://clang.llvm.org/docs/LanguageExtensions.html says: ----------- These function-like macros take a single identifier argument that is the name of a feature. __has_feature evaluates to 1 if the feature is both supported by Clang and standardized in the current language standard or 0 if not (but see below), while __has_extension evaluates to 1 if the feature is supported by Clang in the current language (either as a language extension or a standard language feature) or 0 if not. They can be used like this: #ifndef __has_feature // Optional of course. #define __has_feature(x) 0 // Compatibility with non-clang compilers. #endif #ifndef __has_extension #define __has_extension __has_feature // Compatibility with pre-3.0 compilers. #endif ... #if __has_feature(cxx_rvalue_references) // This code will only be compiled with the -std=c++11 and -std=gnu++11 // options, because rvalue references are only standardized in C++11. #endif #if __has_extension(cxx_rvalue_references) // This code will be compiled with the -std=c++11, -std=gnu++11, -std=c++98 // and -std=gnu++98 options, because rvalue references are supported as a // language extension in C++98. #endif ---------
Comment #1 by dlang-bot — 2023-01-09T22:50:31Z
@WalterBright created dlang/dmd pull request #14799 "fix Issue 23616 - ImportC: clang __has_feature and __has_extension no…" fixing this issue: - fix Issue 23616 - ImportC: clang __has_feature and __has_extension not recognized https://github.com/dlang/dmd/pull/14799
Comment #2 by dlang-bot — 2023-01-10T18:31:06Z
dlang/dmd pull request #14799 "fix Issue 23616 - ImportC: clang __has_feature and __has_extension no…" was merged into master: - ff13a7c69e25dcafc9a07a0dae5ce40604339c80 by Walter Bright: fix Issue 23616 - ImportC: clang __has_feature and __has_extension not recognized https://github.com/dlang/dmd/pull/14799