[cfe-dev] [PATCH] New syntax and functionality for __has_attribute

Nico Rieck nico.rieck at gmail.com
Sat Jan 11 12:56:23 PST 2014

On 11.01.2014 21:06, Aaron Ballman wrote:
> #if __has_attribute(dllexport)
>   #define DLLEXPORT __attribute__((dllexport))
> #else
>   #define DLLEXPORT
> #endif
> void func(void) DLLEXPORT;
> If you were to use this code today in clang, it would fail to compile.
>  __has_attribute(dllexport) will be replaced with 1, and so the
> resulting code would become: void func(void)
> __attribute__((dllexport));  However, we do not support dllexport with
> that syntax (we only support __declspec(dllexport)). So the code would
> look reasonable, but fail to compile.

How will a more advanced __has_attribute help here since GCC and MSVC
all reject this trailing attribute (and Clang rightfully warns about this)?


More information about the cfe-dev mailing list