File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,27 @@ static void print_buf_plain(const unsigned char *buf, size_t len) {
51
51
# define SECP256K1_INLINE inline
52
52
# endif
53
53
54
+ /** Assert statically that expr is true.
55
+ *
56
+ * This is a statement-like macro and can only be used inside functions.
57
+ */
58
+ #define STATIC_ASSERT (expr ) do { \
59
+ switch(0) { \
60
+ case 0: \
61
+ /* If expr evaluates to 0, we have two case labels "0", which is illegal. */ \
62
+ case /* ERROR: static assertion failed */ (expr ): \
63
+ ; \
64
+ } \
65
+ } while (0 )
66
+
54
67
/** Assert statically that expr is an integer constant expression, and run stmt.
55
68
*
56
69
* Useful for example to enforce that magnitude arguments are constant.
57
70
*/
58
71
#define ASSERT_INT_CONST_AND_DO (expr , stmt ) do { \
59
72
switch(42) { \
60
- case /* ERROR: integer argument is not constant */ expr : \
73
+ /* C allows only integer constant expressions as case labels. */ \
74
+ case /* ERROR: integer argument is not constant */ (expr): \
61
75
break; \
62
76
default: ; \
63
77
} \
You can’t perform that action at this time.
0 commit comments