__has_include__ is problematic

Nathan Sidwell nathan@acm.org
Tue Jan 15 12:27:00 GMT 2019


>> Why not give the wierdo __has_include__ an unspellable name?
>> ('builtin<SPACE>has<SPACE>include') and take care constructing the
>> __has_include macro expansion to have a token with exactly that
>> spelling?
> 
> Wouldn't that break -dM rather horribly?
pah!
> 

However, the following thinks __DATE__ is a defined macro, so there must 
be some other subtlety with __has_include?

nathans@zathras:6>gcc -xc - <<EOF
#ifdef __DATE__
#error DATE IS A MACRO
#endif
EOF
<stdin>:2:2: error: #error DATE IS A MACRO

(typing that makes me realize why users think it is __has_include__, 
that's a really unfortunate name to use for an implementation detail)

nathan
-- 
Nathan Sidwell



More information about the Gcc mailing list