From 24c8d575e588d557d28f4011becb753421346860 Mon Sep 17 00:00:00 2001 From: invertego Date: Fri, 6 Oct 2023 16:02:01 -0700 Subject: [PATCH] wdmks: declare GUIDs with selectany attribute (#846) * wdmks: declare GUIDs with selectany attribute Match the behavior of guiddef.h in both mingw and the Windows SDK headers. This prevents linking errors caused by multiply defined symbols when linking against certain Windows SDK libs (like dxguid.lib). * Make sure this works even if DECLSPEC_SELECTANY is not defined --------- Co-authored-by: Ross Bencina --- src/hostapi/wdmks/pa_win_wdmks.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hostapi/wdmks/pa_win_wdmks.c b/src/hostapi/wdmks/pa_win_wdmks.c index bafc970d3..36cb396a8 100644 --- a/src/hostapi/wdmks/pa_win_wdmks.c +++ b/src/hostapi/wdmks/pa_win_wdmks.c @@ -164,12 +164,17 @@ Default is to use the pin category. #define DYNAMIC_GUID(data) {data} #define _NTRTL_ /* Turn off default definition of DEFINE_GUIDEX */ #undef DEFINE_GUID +#ifdef DECLSPEC_SELECTANY +#define PA_DECLSPEC_SELECTANY DECLSPEC_SELECTANY +#else +#define PA_DECLSPEC_SELECTANY +#endif #if defined(__clang__) || (defined(_MSVC_TRADITIONAL) && !_MSVC_TRADITIONAL) /* clang-cl and new msvc preprocessor: avoid too many arguments error */ - #define DEFINE_GUID(n, ...) EXTERN_C const GUID n = {__VA_ARGS__} + #define DEFINE_GUID(n, ...) EXTERN_C const GUID PA_DECLSPEC_SELECTANY n = {__VA_ARGS__} #define DEFINE_GUID_THUNK(n, ...) DEFINE_GUID(n, __VA_ARGS__) #define DEFINE_GUIDEX(n) DEFINE_GUID_THUNK(n, STATIC_##n) #else - #define DEFINE_GUID(n, data) EXTERN_C const GUID n = {data} + #define DEFINE_GUID(n, data) EXTERN_C const GUID PA_DECLSPEC_SELECTANY n = {data} #define DEFINE_GUID_THUNK(n, data) DEFINE_GUID(n, data) #define DEFINE_GUIDEX(n) DEFINE_GUID_THUNK(n, STATIC_##n) #endif /* __clang__, !_MSVC_TRADITIONAL */