field: Static-assert that int args affecting magnitude are constant
See #1001.
This commit is contained in:
13
src/util.h
13
src/util.h
@@ -51,6 +51,19 @@ static void print_buf_plain(const unsigned char *buf, size_t len) {
|
||||
# define SECP256K1_INLINE inline
|
||||
# endif
|
||||
|
||||
/** Assert statically that expr is an integer constant expression, and run stmt.
|
||||
*
|
||||
* Useful for example to enforce that magnitude arguments are constant.
|
||||
*/
|
||||
#define ASSERT_INT_CONST_AND_DO(expr, stmt) do { \
|
||||
switch(42) { \
|
||||
case /* ERROR: integer argument is not constant */ expr: \
|
||||
break; \
|
||||
default: ; \
|
||||
} \
|
||||
stmt; \
|
||||
} while(0)
|
||||
|
||||
typedef struct {
|
||||
void (*fn)(const char *text, void* data);
|
||||
const void* data;
|
||||
|
||||
Reference in New Issue
Block a user