From: Andrew Deason Date: Fri, 13 Feb 2015 19:11:09 +0000 (-0600) Subject: opr: Add opr_StaticAssert X-Git-Tag: upstream/1.8.0_pre1^2~45 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=a13ea7038ebe262ba1e5387f4a3b12897bd8822b;p=packages%2Fo%2Fopenafs.git opr: Add opr_StaticAssert Add a static assert macro, for asserting that certain build-time expressions are true. Change-Id: I33b0e7168f041e8e8406710d05689e044af45fad Reviewed-on: https://gerrit.openafs.org/11792 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- diff --git a/src/opr/opr.h b/src/opr/opr.h index a6aaaf2fe..5891a707f 100644 --- a/src/opr/opr.h +++ b/src/opr/opr.h @@ -54,6 +54,13 @@ extern void opr_AssertFailU(const char *, const char *, int) AFS_NORETURN; # define opr_Verify(ex) __opr_Verify(ex) #endif +/* opr_StaticAssert is a static build-time assertion, to assert certain + * static values (such as sizeof results). If the assertion fails, the + * build will fail. */ + +#define opr_StaticAssert(ex) \ + ((void)(sizeof(char[1 - 2 * !(ex)]))) + /* casestrcpy.c */ #define lcstring opr_lcstring #define ucstring opr_ucstring