Skip to content

Commit b447a53

Browse files
committed
Fix more build errors in mingw
This PR incorporates fixes for issues reported in GPUOpen-LibrariesAndSDKs#71
1 parent 08af682 commit b447a53

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/D3D12MemAlloc.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,25 @@
3434
#endif
3535

3636
// Includes needed for MinGW - see #71.
37-
#ifndef _MSC_VER
38-
#include <guiddef.h>
39-
// guiddef.h must be included first.
40-
#include <dxguids.h>
37+
// On older mingw versions, using the Agility SDK will cause linker errors unless dxguids.h is included.
38+
// But on newer mingw versions, the includes aren't necessary thus no need to grab DirectX-Headers.
39+
// Release cycles are slow for LTS distros on Linux, so this codeblock will need to stay for a few years.
40+
#if defined( __MINGW64_VERSION_MAJOR ) && defined( __MINGW64_VERSION_MINOR ) && \
41+
defined( __MINGW64_VERSION_BUGFIX ) && defined( __ID3D12Device8_INTERFACE_DEFINED__ )
42+
# define D12MA_MAKE_MINGW_VERSION( x, y, z ) ( ( x << 20u ) | ( y << 10u ) | ( z ) )
43+
# if D12MA_MAKE_MINGW_VERSION( __MINGW64_VERSION_MAJOR, __MINGW64_VERSION_MINOR, \
44+
__MINGW64_VERSION_BUGFIX ) <= D12MA_MAKE_MINGW_VERSION( 11, 0, 1 )
45+
# if defined( __has_include )
46+
# if !__has_include( <dxguids.h>)
47+
# error \
48+
"mingw or gcc detected. dxguids.h is needed. You can grab it from https://github.com/microsoft/DirectX-Headers or if you're on Ubuntu just run sudo apt install directx-headers-dev"
49+
# endif
50+
# endif
51+
# include <guiddef.h>
52+
53+
# include <dxguids.h>
54+
# endif
55+
# undef D12MA_MAKE_MINGW_VERSION
4156
#endif
4257

4358
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)