When available we use the Clang extension _Static_assert for compile assertion since this is just a C version of the C++11 static assert we should use the C++11 version when possible.
Note this is not always possible since Assertions.h where COMPILE_ASSERT is defined can be used from both C and C++, and COMPILE_ASSERT will therefore still not be available in C for non clang compilers.
Created attachment 195083 [details]
Comment on attachment 195083 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=195083&action=review
> #if COMPILER_SUPPORTS(C_STATIC_ASSERT)
> #define COMPILE_ASSERT(exp, name) _Static_assert((exp), #name)
I think that this should have a comment explaining why we still have this:
// Unlike static_assert below, this also works in plain C code.
That said, I'm unsure if we ever use - or want to use - COMPILE_ASSERT in plain C code.
> +#define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1
Shouldn't this be defined for clang too? The behavior in this patch would not be affected, but it's better to not leave such a tripmine for later IMO.
Created attachment 195266 [details]
Added detection of C++11 static_assert to clang, and C11 _Static_assert to GCC.
Created attachment 195267 [details]
Remove accidentially uploaded change.
Comment on attachment 195267 [details]
Clearing flags on attachment: 195267
Committed r146993: <http://trac.webkit.org/changeset/146993>
All reviewed patches have been landed. Closing bug.