Avoid redefining FFI_GO_CLOSURES defined by libffi headers#206
Merged
Conversation
libffi defines FFI_GO_CLOSURES unconditionally in ffitarget.h on most targets, so pre-defining it in fiddle.h is a macro redefinition there, which MSVC reports as warning C4005 in every compilation unit, e.g. with vcpkg libffi. Restore the conditional definition of GH-134 in extconf.rb, but with macro_defined? instead of the fragile warning text matching that GH-157 removed. FFI_GO_CLOSURES=0 is only needed for old ffi.h that tests `#if FFI_GO_CLOSURES` and warns with -Wundef when the target's ffitarget.h does not define it. #134 #157 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
|
Should we release a new version soon? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Building fiddle with MSVC against libffi whose
ffitarget.hdefinesFFI_GO_CLOSURESunconditionally, for example vcpkg libffi 3.5.2 in a ruby/ruby mswin build, reportswarning C4005: 'FFI_GO_CLOSURES': macro redefinitionin every compilation unit. The pre-definition infiddle.hadded by #157 collides with libffi's own definition. GCC and clang hide the same redefinition because it happens in a system header there.The pre-definition only exists to silence
-Wundefwarnings from oldffi.hthat tests#if FFI_GO_CLOSURESwithout the target defining it, and libffi switched that test to#ifdefin 3.4.5 (libffi/libffi#796). This restores the conditional approach of #134, but detects whether the libffi headers define the macro withmacro_defined?atextconf.rbtime instead of matching compiler-specific warning text, and definesFFI_GO_CLOSURES=0only when they do not. Fiddle itself does not use Go closures, so the macro only affects which declarationsffi.hexposes.I verified on Windows with MSVC that the eight C4005 warnings disappear with vcpkg libffi 3.5.2, and that a simulated old libffi header set with no
FFI_GO_CLOSURESdefinition and an#if FFI_GO_CLOSUREStest still gets-DFFI_GO_CLOSURES=0fromextconf.rb.rake testpasses onx64-mswin64_140.Generated with Claude Code