field: Static-assert that int args affecting magnitude are constant

See #1001.
This commit is contained in:
Tim Ruffing
2023-06-13 13:34:49 +02:00
parent 67214f5f7d
commit be8ff3a02a
6 changed files with 43 additions and 18 deletions

View File

@@ -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;