From 617a55b77549eb87551de3e01eedc50cfbfffb36 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 15 Apr 2026 09:01:19 +0900 Subject: [PATCH] mruby-bigint: avoid C99 compound literal in MPZ_CTX_INIT MPZ_CTX_INIT used a compound literal with designated initializers: mpz_ctx_t ctx##_struct = ((mpz_ctx_t){.mrb = ..., .pool = ...}); Both features are C99-only, and are not accepted by legacy C++ compilers (notably gcc 4.x) when mruby is pulled into a C++ translation unit via the -cxx.cxx wrapper. Replace with plain member assignment so the macro expands to code that is valid under C89/C++98 as well. Co-authored-by: Claude --- mrbgems/mruby-bigint/core/bigint.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mrbgems/mruby-bigint/core/bigint.c b/mrbgems/mruby-bigint/core/bigint.c index 28c1fa678..2c8487152 100644 --- a/mrbgems/mruby-bigint/core/bigint.c +++ b/mrbgems/mruby-bigint/core/bigint.c @@ -50,11 +50,16 @@ typedef struct mpz_context { mpz_pool_t *pool; /* NULL for heap-only operations */ } mpz_ctx_t; -/* Convenience macros for context creation */ +/* Convenience macros for context creation. + * Uses per-member assignment instead of a C99 compound literal with + * designated initializers so the file compiles as C++ on legacy + * toolchains (pre-C++20). */ #define MPZ_CTX_INIT(mrb_ptr, ctx, pool_ptr) \ mpz_pool_t pool ## _storage = {{0}};\ mpz_pool_t *pool_ptr = &pool ## _storage;\ - mpz_ctx_t ctx ## _struct = ((mpz_ctx_t){.mrb = (mrb_ptr), .pool = (pool_ptr)}); \ + mpz_ctx_t ctx ## _struct; \ + ctx ## _struct.mrb = (mrb_ptr); \ + ctx ## _struct.pool = (pool_ptr); \ mpz_ctx_t *ctx = &(ctx ## _struct); /* Access macros for readability */