Commit fdc01373
fdc0137303d7Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(build): define __has_builtin fallback for GCC < 10
GCC < 10 (e.g. Ubuntu 20.04's stock 9.4) doesn't predefine __has_builtin, so #if expressions of the form
#if defined(__GNUC__) || __has_builtin(__builtin_popcount)
trip "missing binary operator before token "("" because the
preprocessor sees __has_builtin as an undefined identifier (replaced
with 0) and then a stray ( after it. lib/sp_bigint.c uses this
pattern in four places.
Define a no-op fallback __has_builtin(x) -> 0 in mruby_shim.h, the
shim header sp_bigint.c already includes. On GCC 10+ / Clang the
compiler's real __has_builtin is left in place by the #ifndef guard;
on older toolchains the fallback makes the || short-circuit cleanly
on defined(__GNUC__).
Closes #55
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- fdc0137303d7
- Parent
- f2785f692d3d
lib/mruby_shim.hmodifiedView file
#include <string.h>#include <assert.h>/* GCC < 10 doesn't predefine __has_builtin, so #if expressions like `defined(__GNUC__) || __has_builtin(...)` choke on the bare token. Provide a no-op fallback so the || short-circuits cleanly on the left when the compiler doesn't support __has_builtin (issue #55). */#ifndef __has_builtin#define __has_builtin(x) 0#endif/* Basic mruby types */typedef int64_t mrb_int;typedef uint64_t mrb_uint;