diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2014-12-05 15:05:29 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2014-12-05 15:05:29 +0000 |
commit | bf260bb264a60e38c82b0e57dd2e9bf8d69249c2 (patch) | |
tree | 504f8c9fd6c1c4e013600da3a4573ee482f8c57c /docs/LanguageExtensions.rst | |
parent | aa8362e18eab808b975eddc5489e1e2e311dce85 (diff) |
Added a new preprocessor macro: __has_declspec_attribute. This can be used as a way to determine whether Clang supports a __declspec spelling for a given attribute, similar to __has_attribute and __has_cpp_attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/LanguageExtensions.rst')
-rw-r--r-- | docs/LanguageExtensions.rst | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/LanguageExtensions.rst b/docs/LanguageExtensions.rst index 5636b8992d..3ca1010e39 100644 --- a/docs/LanguageExtensions.rst +++ b/docs/LanguageExtensions.rst @@ -164,6 +164,33 @@ The attribute name can also be specified with a preceding and following ``__`` (double underscore) to avoid interference from a macro with the same name. For instance, ``__always_inline__`` can be used instead of ``always_inline``. + +``__has_declspec_attribute`` +---------------------------- + +This function-like macro takes a single identifier argument that is the name of +an attribute implemented as a Microsoft-style ``__declspec`` attribute. It +evaluates to 1 if the attribute is supported by the current compilation target, +or 0 if not. It can be used like this: + +.. code-block:: c++ + + #ifndef __has_declspec_attribute // Optional of course. + #define __has_declspec_attribute(x) 0 // Compatibility with non-clang compilers. + #endif + + ... + #if __has_declspec_attribute(dllexport) + #define DLLEXPORT __declspec(dllexport) + #else + #define DLLEXPORT + #endif + ... + +The attribute name can also be specified with a preceding and following ``__`` +(double underscore) to avoid interference from a macro with the same name. For +instance, ``__dllexport__`` can be used instead of ``dllexport``. + ``__is_identifier`` ------------------- |