config: use __declspec(dllexport) on all Windows (MinGW/Clang), not just MSVC#231
Merged
Conversation
visibility("default") is ELF-only and inert for PE/COFF, so on MinGW/Clang
libremidi exported none of its API. Key the dllexport branch on _WIN32 in both
config.hpp and libremidi-c.h.
b49db9a to
7ed7792
Compare
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.
Problem
LIBREMIDI_EXPORTresolved to__attribute__((visibility("default")))on the GCC/Clang path:But
visibilityis an ELF concept. On Windows PE/COFF (MinGW-GCC and Clang targeting*-w64-windows-gnu) it is silently inert — it produces no PE export. So on those toolchains:.dll) built with MinGW/Clang exports none of its API, andlibremidi::reader::parse) exports nothing either.Only the MSVC branch got
__declspec(dllexport).Fix
Key the
dllexportbranch on_WIN32so it covers all Windows compilers (MSVC and MinGW/Clang).__declspec(dllexport)is supported by GCC/Clang on mingw and is the correct PE mechanism.Verification
On
x86_64-w64-windows-gnu, compiling:llvm-objdump -s --section=.drectveshows a-export:directive only fordll_func—vis_funcproduces none. Confirmed against the real symptom: a MinGW/Clang-built static libremidi shows 0-export:directives; after this change its public API (reader,observer,available_apis, …) exports correctly.This should be validated by the existing MSYS/MinGW CI matrix.