Yeah, I didn't want to get too technical because I think it gets even more confusing at that point. It can be macro expanded, so long as the expansion happens as part of the expression in a #if or #elif. Put another way, it can't be used as a constant expression outside of a preprocessor directive.
If anyone can think of a better wording for the docs, I'd be all ears! ~Aaron On Wed, Jan 16, 2013 at 3:01 PM, Jordan Rose <[email protected]> wrote: > This confused me because I thought it implied that this was disallowed: > > #define HAS_STDIO __has_include(<stdio.h>) > #if HAS_STDIO > // do something > #endif > > But this is still allowed. I'm not sure how to rephrase this to make it > clearer, though. > > > On Jan 16, 2013, at 11:51 , Aaron Ballman <[email protected]> wrote: > >> Author: aaronballman >> Date: Wed Jan 16 13:51:19 2013 >> New Revision: 172643 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=172643&view=rev >> Log: >> Adding verbiage to the Language Extensions document about __has_include and >> __has_include_next only being allowed within preprocessor directives. >> >> Modified: >> cfe/trunk/docs/LanguageExtensions.rst >> >> Modified: cfe/trunk/docs/LanguageExtensions.rst >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=172643&r1=172642&r2=172643&view=diff >> ============================================================================== >> --- cfe/trunk/docs/LanguageExtensions.rst (original) >> +++ cfe/trunk/docs/LanguageExtensions.rst Wed Jan 16 13:51:19 2013 >> @@ -140,7 +140,8 @@ >> Not all developments systems have the same include files. The >> :ref:`langext-__has_include` and :ref:`langext-__has_include_next` macros >> allow >> you to check for the existence of an include file before doing a possibly >> -failing ``#include`` directive. >> +failing ``#include`` directive. Include file checking macros must be used >> +as expressions in #if or #elif preprocessing directives. >> >> .. _langext-__has_include: >> >> >> >> _______________________________________________ >> cfe-commits mailing list >> [email protected] >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
