From a13ea7038ebe262ba1e5387f4a3b12897bd8822b Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 13 Feb 2015 13:11:09 -0600 Subject: [PATCH] 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 --- src/opr/opr.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/opr/opr.h b/src/opr/opr.h index a6aaaf2..5891a70 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 -- 1.9.4