Skip to content

Commit

Permalink
wdmks: declare GUIDs with selectany attribute (#846)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
invertego and RossBencina authored Oct 6, 2023
1 parent 6c9e455 commit 24c8d57
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/hostapi/wdmks/pa_win_wdmks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 24c8d57

Please sign in to comment.