PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.39k stars 291 forks source link

wdmks: declare GUIDs with selectany attribute #846

Closed invertego closed 9 months ago

invertego commented 9 months ago

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).

invertego commented 9 months ago

I encountered this issue when building MAME, which currently recommends disabling portaudio when building with VS.

The exact linking error is along these lines: dxguid.lib(dxguid.obj) : error LNK2005: KSDATAFORMAT_SUBTYPE_MIDI already defined in portaudio.lib(pa_win_wdmks.obj)

I'm honestly not sure this whole section of code - which seems to be just duplicating portions of guiddef.h - even ought to exist in portaudio. It appears to go back at least 16 years in age. That said, not being familiar with your build requirements, I thought I'd offer a minimally disruptive change.

mingw reference: https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/include/guiddef.h selectany reference: https://learn.microsoft.com/en-us/cpp/cpp/selectany