summaryrefslogtreecommitdiff
path: root/py/runtime.h
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2025-04-22 14:53:07 +0200
committerstijn <stijn@ignitron.net>2025-04-24 15:55:06 +0200
commit02eea0da2448f2be9bcc04f340a6a0a1fae18f7b (patch)
treeb2d30249460d45bf442033238698b06786e07c0d /py/runtime.h
parent076e07197e35cdc0e23bd6f45fd21a36e2162e88 (diff)
py: Make struct-initializing macros compatible with C++.
This requires explicitly naming and initializing all members so add that where needed and possible. For MP_DEFINE_NLR_JUMP_CALLBACK_FUNCTION_1 this would require initializing the .callback member, but that's a bit of a waste since the macro is always followed by a call to nlr_push_jump_callback() to initialize exactly that member, so rewrite the macro without initializers. Signed-off-by: stijn <stijn@ignitron.net>
Diffstat (limited to 'py/runtime.h')
-rw-r--r--py/runtime.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/py/runtime.h b/py/runtime.h
index e8e5a758f..77cdd0e20 100644
--- a/py/runtime.h
+++ b/py/runtime.h
@@ -30,12 +30,12 @@
#include "py/pystack.h"
#include "py/cstack.h"
-// For use with mp_call_function_1_from_nlr_jump_callback.
+// Initialize an nlr_jump_callback_node_call_function_1_t struct for use with
+// nlr_push_jump_callback(&ctx.callback, mp_call_function_1_from_nlr_jump_callback);
#define MP_DEFINE_NLR_JUMP_CALLBACK_FUNCTION_1(ctx, f, a) \
- nlr_jump_callback_node_call_function_1_t ctx = { \
- .func = (void (*)(void *))(f), \
- .arg = (a), \
- }
+ nlr_jump_callback_node_call_function_1_t ctx; \
+ ctx.func = (void (*)(void *))(f); \
+ ctx.arg = (a)
typedef enum {
MP_VM_RETURN_NORMAL,