Skip to content

Commit 153e838

Browse files
authored
Fix various build warnings (#1473)
1 parent e4c0b26 commit 153e838

File tree

8 files changed

+30
-4
lines changed

8 files changed

+30
-4
lines changed

cppwinrt/component_writers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ void* __stdcall %_get_activation_factory([[maybe_unused]] std::wstring_view cons
175175
int32_t __stdcall WINRT_CanUnloadNow() noexcept
176176
{
177177
#ifdef _WRL_MODULE_H_
178+
#ifdef _MSC_VER
179+
#pragma warning(suppress: 4324) // structure was padded due to alignment specifier
180+
#endif
178181
if (!::Microsoft::WRL::Module<::Microsoft::WRL::InProc>::GetModule().Terminate())
179182
{
180183
return 1;

prebuild/prebuild.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<IntrinsicFunctions>true</IntrinsicFunctions>
121121
<AdditionalIncludeDirectories>..\cppwinrt</AdditionalIncludeDirectories>
122122
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
123+
<ControlFlowGuard>Guard</ControlFlowGuard>
123124
</ClCompile>
124125
<Link>
125126
<SubSystem>Console</SubSystem>
@@ -134,6 +135,7 @@
134135
<IntrinsicFunctions>true</IntrinsicFunctions>
135136
<AdditionalIncludeDirectories>..\cppwinrt</AdditionalIncludeDirectories>
136137
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
138+
<ControlFlowGuard>Guard</ControlFlowGuard>
137139
</ClCompile>
138140
<Link>
139141
<SubSystem>Console</SubSystem>
@@ -148,6 +150,7 @@
148150
<IntrinsicFunctions>true</IntrinsicFunctions>
149151
<AdditionalIncludeDirectories>..\cppwinrt</AdditionalIncludeDirectories>
150152
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
153+
<ControlFlowGuard>Guard</ControlFlowGuard>
151154
</ClCompile>
152155
<Link>
153156
<SubSystem>Console</SubSystem>

strings/base_composable.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ namespace winrt::impl
44
template <typename D>
55
struct composable_factory
66
{
7+
#ifdef _MSC_VER
8+
#pragma warning(push)
9+
#pragma warning(disable: 4702) // Compiler bug causing spurious "unreachable code" warnings
10+
#endif
711
template <typename I, typename... Args>
812
static I CreateInstance(const Windows::Foundation::IInspectable& outer, Windows::Foundation::IInspectable& inner, Args&&... args)
913
{
1014
static_assert(std::is_base_of_v<Windows::Foundation::IInspectable, I>, "Requested interface must derive from winrt::Windows::Foundation::IInspectable");
1115
inner = CreateInstanceImpl(outer, std::forward<Args>(args)...);
1216
return inner.as<I>();
1317
}
18+
#ifdef _MSC_VER
19+
#pragma warning(pop)
20+
#endif
1421

1522
private:
1623
template <typename... Args>

strings/base_implements.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,10 @@ namespace winrt::impl
13901390

13911391
WINRT_EXPORT namespace winrt
13921392
{
1393+
#ifdef _MSC_VER
1394+
#pragma warning(push)
1395+
#pragma warning(disable: 4702) // Compiler bug causing spurious "unreachable code" warnings
1396+
#endif
13931397
template <typename D, typename... Args>
13941398
auto make(Args&&... args)
13951399
{
@@ -1443,6 +1447,9 @@ WINRT_EXPORT namespace winrt
14431447
return { impl::create_and_initialize<D>(std::forward<Args>(args)...), take_ownership_from_abi };
14441448
}
14451449
}
1450+
#ifdef _MSC_VER
1451+
#pragma warning(pop)
1452+
#endif
14461453

14471454
template <typename... FactoryClasses>
14481455
inline void clear_factory_static_lifetime()

test/old_tests/Component/Component.idl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ namespace Component
243243
HRESULT Create([in] Windows.Foundation.Collections.IVectorView<HSTRING>* _in, [out, retval] FastInputVector** _out);
244244
};
245245

246+
midl_pragma warning(disable: 4066) // A member name has been qualified with an interface name because name collisions occurred across interface members on a runtime class.
247+
246248
[version(1.0), activatable(IFastInputVectorFactory, 1.0)]
247249
runtimeclass FastInputVector
248250
{
@@ -271,6 +273,8 @@ namespace Component
271273
interface Windows.Foundation.Collections.IMapView<HSTRING, HSTRING>;
272274
};
273275

276+
midl_pragma warning(default: 4066)
277+
274278
//
275279
// Boxing support for enums and their underlying types.
276280
//

test/test/fast_iterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ TEST_CASE("fast_iterator")
4848
REQUIRE(2 - (vbegin + 4) > vbegin);
4949
REQUIRE(vbegin < vbegin + 2);
5050
REQUIRE(vbegin + 2 - 2 == vbegin);
51-
REQUIRE(end(v) - begin(v) == v.Size());
51+
REQUIRE(static_cast<uint32_t>(end(v) - begin(v)) == v.Size());
5252
REQUIRE((begin(v) + 3)[-1] == 4);
5353
}
5454
{

test/test_component/OverloadClass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ namespace winrt::test_component::implementation
88
{
99
throw hresult_not_implemented();
1010
}
11-
void OverloadClass::Overload(int a)
11+
void OverloadClass::Overload(int /*a*/)
1212
{
1313
throw hresult_not_implemented();
1414
}
15-
void OverloadClass::Overload(int a, int b)
15+
void OverloadClass::Overload(int /*a*/, int /*b*/)
1616
{
1717
throw hresult_not_implemented();
1818
}
19-
void OverloadClass::Overload(int a, int b, int c)
19+
void OverloadClass::Overload(int /*a*/, int /*b*/, int /*c*/)
2020
{
2121
throw hresult_not_implemented();
2222
}

test/test_component_base/HierarchyB.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "pch.h"
22
#include "HierarchyB.h"
33

4+
#pragma warning(disable: 4702)
5+
46
namespace winrt::test_component_base::implementation
57
{
68
HierarchyB::HierarchyB(hstring const& name)

0 commit comments

Comments
 (0)