diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 403a958..c0e0420 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,8 @@ name: Build on: push: - branches: [main] + branches: + - '**' pull_request: branches: [main] diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ed465d..ab37cf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,13 @@ file(GLOB RAW_PDB_SRCS third_party/raw_pdb/src/*.cpp) add_library(raw_pdb STATIC ${RAW_PDB_SRCS}) target_include_directories(raw_pdb PUBLIC third_party/raw_pdb/src) target_compile_features(raw_pdb PRIVATE cxx_std_11) +# PDB_CRT.h forward-declares printf/memcmp/etc with __cdecl which conflicts +# with MinGW. Force-include a prefix header that pulls in the real CRT headers +# and strips __cdecl so the redeclarations are compatible. +if(MINGW) + target_compile_options(raw_pdb PUBLIC + -include "${CMAKE_CURRENT_SOURCE_DIR}/cmake/raw_pdb_prefix.h") +endif() if(WIN32) target_link_libraries(raw_pdb PRIVATE rpcrt4) endif() diff --git a/cmake/raw_pdb_prefix.h b/cmake/raw_pdb_prefix.h new file mode 100644 index 0000000..81b1d53 --- /dev/null +++ b/cmake/raw_pdb_prefix.h @@ -0,0 +1,29 @@ +// Force-included before every raw_pdb translation unit (and consumers). +// PDB_CRT.h forward-declares printf/memcmp/etc with extern "C" __cdecl, +// which conflicts with MinGW's CRT headers (C++ linkage, no __cdecl). +// +// Fix: include the real CRT headers, then include PDB_CRT.h with function +// names macro-renamed to harmless dummies. This triggers #pragma once so +// no raw_pdb source file ever processes PDB_CRT.h's conflicting declarations. +// +// Guarded with __cplusplus because PUBLIC propagation applies this to C +// sources (fadec) where PDB_CRT.h is irrelevant and doesn't exist. +#ifdef __cplusplus +#include +#include + +#undef __cdecl +#define __cdecl + +#define printf _pdb_crt_unused_printf +#define memcmp _pdb_crt_unused_memcmp +#define memcpy _pdb_crt_unused_memcpy +#define strlen _pdb_crt_unused_strlen +#define strcmp _pdb_crt_unused_strcmp +#include "Foundation/PDB_CRT.h" +#undef printf +#undef memcmp +#undef memcpy +#undef strlen +#undef strcmp +#endif