Issue 23616 - ImportC: clang __has_feature and __has_extension not recognized
Summary: ImportC: clang __has_feature and __has_extension not recognized
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: ImportC, pull
Depends on:
Blocks:
 
Reported: 2023-01-09 22:30 UTC by Walter Bright
Modified: 2023-01-10 18:31 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2023-01-09 22:30:26 UTC
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 Dlang Bot 2023-01-09 22:50:31 UTC
@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 Dlang Bot 2023-01-10 18:31:06 UTC
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