Skip to content

Commit 57c56c1

Browse files
authored
Inclusion order can break builds with SDK headers (#525)
1 parent 3307d54 commit 57c56c1

File tree

8 files changed

+26
-9
lines changed

8 files changed

+26
-9
lines changed

strings/base_implements.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace winrt::impl
3737
template <template <typename> typename Condition, typename T>
3838
using tuple_if = typename tuple_if_base<Condition, T>::type;
3939

40-
#ifdef __IUnknown_INTERFACE_DEFINED__
40+
#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
4141

4242
template <typename T>
4343
struct is_interface : std::disjunction<std::is_base_of<Windows::Foundation::IInspectable, T>, std::conjunction<std::is_base_of<::IUnknown, T>, std::negation<is_implements<T>>>> {};
@@ -469,7 +469,7 @@ namespace winrt::impl
469469
}
470470
};
471471

472-
#ifdef __IUnknown_INTERFACE_DEFINED__
472+
#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
473473

474474
template <typename D, typename I>
475475
struct producer<D, I, std::enable_if_t<std::is_base_of_v< ::IUnknown, I> && !is_implements_v<I>>> : I

strings/base_macros.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@
4444
#undef _WINDOWS_NUMERICS_BEGIN_NAMESPACE_
4545
#undef _WINDOWS_NUMERICS_END_NAMESPACE_
4646
#endif
47+
48+
#ifdef __IUnknown_INTERFACE_DEFINED__
49+
#define WINRT_IMPL_IUNKNOWN_DEFINED
50+
#endif

strings/base_meta.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace winrt::impl
118118
};
119119

120120
template <typename T>
121-
#ifdef __IUnknown_INTERFACE_DEFINED__
121+
#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
122122
#ifdef __clang__
123123
inline const guid guid_v{ __uuidof(T) };
124124
#else

strings/base_reference_produce.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace winrt::impl
197197
static auto make(guid const& value) { return Windows::Foundation::PropertyValue::CreateGuid(value); }
198198
};
199199

200-
#ifdef __IUnknown_INTERFACE_DEFINED__
200+
#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
201201
template <>
202202
struct reference_traits<GUID>
203203
{
@@ -299,7 +299,7 @@ WINRT_EXPORT namespace winrt
299299
return static_cast<T>(value.as<Windows::Foundation::IReference<std::underlying_type_t<T>>>().Value());
300300
}
301301
}
302-
#ifdef __IUnknown_INTERFACE_DEFINED__
302+
#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
303303
else if constexpr (std::is_same_v<T, GUID>)
304304
{
305305
return value.as<Windows::Foundation::IReference<guid>>().Value();
@@ -349,7 +349,7 @@ WINRT_EXPORT namespace winrt
349349
return static_cast<T>(temp.Value());
350350
}
351351
}
352-
#ifdef __IUnknown_INTERFACE_DEFINED__
352+
#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
353353
else if constexpr (std::is_same_v<T, GUID>)
354354
{
355355
if (auto temp = value.try_as<Windows::Foundation::IReference<guid>>())

strings/base_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ WINRT_EXPORT namespace winrt
5959
{
6060
}
6161

62-
#ifdef __IUnknown_INTERFACE_DEFINED__
62+
#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
6363

6464
constexpr guid(GUID const& value) noexcept :
6565
Data1(value.Data1),
@@ -112,7 +112,7 @@ WINRT_EXPORT namespace winrt::Windows::Foundation
112112

113113
namespace winrt::impl
114114
{
115-
#ifdef __IUnknown_INTERFACE_DEFINED__
115+
#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
116116
using hresult_type = long;
117117
using count_type = unsigned long;
118118
using guid_type = GUID;

strings/base_windows.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ WINRT_EXPORT namespace winrt
335335
}
336336
}
337337

338-
#ifdef __IUnknown_INTERFACE_DEFINED__
338+
#ifdef WINRT_IMPL_IUNKNOWN_DEFINED
339339

340340
inline ::IUnknown* get_unknown(Windows::Foundation::IUnknown const& object) noexcept
341341
{

test/test/guid_include.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "winrt/base.h"
2+
#include <Unknwn.h>
3+
#include "winrt/Windows.Foundation.h"

test/test/test.vcxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,16 @@
363363
</ClCompile>
364364
<ClCompile Include="GetMany.cpp" />
365365
<ClCompile Include="get_activation_factory.cpp" />
366+
<ClCompile Include="guid_include.cpp">
367+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
368+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
369+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">NotUsing</PrecompiledHeader>
370+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">NotUsing</PrecompiledHeader>
371+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
372+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
373+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
374+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
375+
</ClCompile>
366376
<ClCompile Include="hstring_empty.cpp" />
367377
<ClCompile Include="iid_ppv_args.cpp" />
368378
<ClCompile Include="inspectable_interop.cpp">

0 commit comments

Comments
 (0)