From: Richard Smith Date: Thu, 11 Jul 2013 00:27:05 +0000 (+0000) Subject: Fix documentation: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e0a65e27d06504e474ccb9554b67b522d25f940;p=clang Fix documentation: #if defined(__has_foo("X")) && __has_foo("X") is not a correct way to portably use __has_foo, because it is expanded to #if 0 && 0("X") ... which is ill-formed. Also add a missing ')'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186047 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LanguageExtensions.rst b/docs/LanguageExtensions.rst index 54f67ce280..928b09524b 100644 --- a/docs/LanguageExtensions.rst +++ b/docs/LanguageExtensions.rst @@ -159,12 +159,16 @@ include paths, or 0 otherwise: # include "myinclude.h" #endif +To test for this feature, use ``#if defined(__has_include)``: + +.. code-block:: c++ + // To avoid problem with non-clang compilers not having this macro. - #if defined(__has_include) && __has_include("myinclude.h") + #if defined(__has_include) + #if __has_include("myinclude.h") # include "myinclude.h" #endif - -To test for this feature, use ``#if defined(__has_include)``. + #endif .. _langext-__has_include_next: @@ -185,9 +189,11 @@ or 0 otherwise: #endif // To avoid problem with non-clang compilers not having this macro. - #if defined(__has_include_next) && __has_include_next("myinclude.h") + #if defined(__has_include_next) + #if __has_include_next("myinclude.h") # include_next "myinclude.h" #endif + #endif Note that ``__has_include_next``, like the GNU extension ``#include_next`` directive, is intended for use in headers only, and will issue a warning if @@ -1695,7 +1701,7 @@ are accepted with the ``__attribute__((foo))`` syntax are also accepted as `_, `GCC variable attributes `_, and `GCC type attributes -`_. As with the GCC +`_). As with the GCC implementation, these attributes must appertain to the *declarator-id* in a declaration, which means they must go either at the start of the declaration or immediately after the name being declared.