www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23616] New: ImportC: clang __has_feature and __has_extension

https://issues.dlang.org/show_bug.cgi?id=23616

          Issue ID: 23616
           Summary: ImportC: clang __has_feature and __has_extension not
                    recognized
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

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
---------

--
Jan 09 2023