Skip to content

Commit 2575735

Browse files
authored
Merge pull request #6791 from mruby/fix/bigint-cxx-compat
2 parents eb87d59 + 617a55b commit 2575735

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

mrbgems/mruby-bigint/core/bigint.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,16 @@ typedef struct mpz_context {
5050
mpz_pool_t *pool; /* NULL for heap-only operations */
5151
} mpz_ctx_t;
5252

53-
/* Convenience macros for context creation */
53+
/* Convenience macros for context creation.
54+
* Uses per-member assignment instead of a C99 compound literal with
55+
* designated initializers so the file compiles as C++ on legacy
56+
* toolchains (pre-C++20). */
5457
#define MPZ_CTX_INIT(mrb_ptr, ctx, pool_ptr) \
5558
mpz_pool_t pool ## _storage = {{0}};\
5659
mpz_pool_t *pool_ptr = &pool ## _storage;\
57-
mpz_ctx_t ctx ## _struct = ((mpz_ctx_t){.mrb = (mrb_ptr), .pool = (pool_ptr)}); \
60+
mpz_ctx_t ctx ## _struct; \
61+
ctx ## _struct.mrb = (mrb_ptr); \
62+
ctx ## _struct.pool = (pool_ptr); \
5863
mpz_ctx_t *ctx = &(ctx ## _struct);
5964

6065
/* Access macros for readability */

0 commit comments

Comments
 (0)