Michael Paquier <mich...@paquier.xyz> writes: > Indeed the bot is happy now. By looking at the patch, one would note > that what it just does is unifying the fallback "hack-ish" > implementations so as C and C++ use the same thing, which is the > fallback implementation for C of HEAD. I would prefer hear first from > more people to see if they like this change. Or not.
I looked at this and tried it on an old (non HAVE__STATIC_ASSERT) gcc version. Seems to work, but I have a couple cosmetic suggestions: 1. The comment block above this was never updated to mention that we're now catering for C++ too. Maybe something like * gcc 4.6 and up supports _Static_assert(), but there are bizarre syntactic * placement restrictions. Macros StaticAssertStmt() and StaticAssertExpr() * make it safe to use as a statement or in an expression, respectively. * The macro StaticAssertDecl() is suitable for use at file scope (outside of * any function). * + * On recent C++ compilers, we can use standard static_assert(). + * * Otherwise we fall back on a kluge that assumes the compiler will complain * about a negative width for a struct bit-field. This will not include a * helpful error message, but it beats not getting an error at all. 2. I think you could simplify the #elif to just #elif defined(__cplusplus) && __cpp_static_assert >= 200410 Per the C standard, an unrecognized identifier in an #if condition is replaced by zero. So the condition will come out false as desired if __cpp_static_assert isn't defined; you don't need to test that separately. regards, tom lane