From 0fe23bd335abb9c4cbeeb7599f3e9cd04aea99a0 Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Thu, 20 Aug 2026 16:49:23 +0200 Subject: [PATCH] cpp2ffi: don't let the generated-header test link The test at the end of cimgui_generation passes neither -c nor -E, so gcc compiles the .h into a precompiled header and then still tries to link, failing with "undefined reference to `main'" whenever the toolchain puts something link-ish on the command line (a -Wl,... or -L from a spec file or a compiler wrapper). That aborts generation via the assert in get_cdefs. -fsyntax-only is all this check needs, since only the diagnostics are inspected and the get_cdefs return value is discarded. -x c is needed too, without it gcc 5 stays in precompiled-header mode and fails with "output filename specified twice". --- generator/cpp2ffi.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/cpp2ffi.lua b/generator/cpp2ffi.lua index ba70c3e..cc6c145 100644 --- a/generator/cpp2ffi.lua +++ b/generator/cpp2ffi.lua @@ -3476,7 +3476,7 @@ function M.Parser() if COMPILER=="gcc" then local include_cmd = COMPILER=="cl" and [[ /I ]] or [[ -I ]] local extra_includes = include_cmd.." ../../cimgui " - local CPRE = COMPILER..[[ -std=c99 -DCIMGUI_DEFINE_ENUMS_AND_STRUCTS -DIMGUI_ENABLE_FREETYPE ]] ..extra_includes.. "./output/"..name..".h" + local CPRE = COMPILER..[[ -fsyntax-only -x c -std=c99 -DCIMGUI_DEFINE_ENUMS_AND_STRUCTS -DIMGUI_ENABLE_FREETYPE ]] ..extra_includes.. "./output/"..name..".h" print(CPRE) get_cdefs(CPRE,"name") end