Fix StaticAssertExpr() under C++
authorPeter Eisentraut
Mon, 19 Feb 2018 03:20:54 +0000 (22:20 -0500)
committerPeter Eisentraut
Mon, 19 Feb 2018 03:28:11 +0000 (22:28 -0500)
The previous code didn't compile, because static_assert() must end with
a semicolon.  To fix, wrap it in a block, similar to the C code.

src/include/c.h

index 6b55181e0a1eae0f9b19d327264f6c5e1aaadfe4..37c0c3919902a48a542a05a8452fdd8ce4abbb82 100644 (file)
@@ -791,7 +791,7 @@ extern void ExceptionalCondition(const char *conditionName,
 #define StaticAssertStmt(condition, errmessage) \
    static_assert(condition, errmessage)
 #define StaticAssertExpr(condition, errmessage) \
-   StaticAssertStmt(condition, errmessage)
+   ({ static_assert(condition, errmessage); })
 #else
 #define StaticAssertStmt(condition, errmessage) \
    do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0)