summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar lat9nq2023-06-18 19:57:14 -0400
committerGravatar lat9nq2023-07-21 10:56:55 -0400
commit3f0cc544cf7184adacec22aedd81f6d796bbea31 (patch)
tree16bb9ab8dc1b20fe4767a6f0bf94954f8cfad7d6 /src
parentsettings_setting: Fix MSVC error (diff)
downloadyuzu-3f0cc544cf7184adacec22aedd81f6d796bbea31.tar.gz
yuzu-3f0cc544cf7184adacec22aedd81f6d796bbea31.tar.xz
yuzu-3f0cc544cf7184adacec22aedd81f6d796bbea31.zip
common,yuzu-qt: Avoid explicit instantiation on old clang
Clang versions < 15 have compile issues with explicit instantiation. Disable it for these versions.
Diffstat (limited to 'src')
-rw-r--r--src/common/CMakeLists.txt11
-rw-r--r--src/common/settings.cpp2
-rw-r--r--src/common/settings.h2
-rw-r--r--src/yuzu/CMakeLists.txt6
-rw-r--r--src/yuzu/uisettings.cpp2
-rw-r--r--src/yuzu/uisettings.h2
6 files changed, 22 insertions, 3 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 09e7e673e..cf05ae364 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -197,10 +197,15 @@ if (MSVC)
197 /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data 197 /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
198 /we4800 # Implicit conversion from 'type' to bool. Possible information loss 198 /we4800 # Implicit conversion from 'type' to bool. Possible information loss
199 ) 199 )
200else() 200endif()
201
202if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
201 target_compile_options(common PRIVATE 203 target_compile_options(common PRIVATE
202 $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation> 204 -fsized-deallocation
203 $<$<CXX_COMPILER_ID:Clang>:-Werror=unreachable-code-aggressive> 205 -Werror=unreachable-code-aggressive
206 )
207 target_compile_definitions(common PRIVATE
208 $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,15>:_CANNOT_EXPLICITLY_INSTANTIATE>
204 ) 209 )
205endif() 210endif()
206 211
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index a1cc76a38..f4eb2d2fb 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -25,6 +25,7 @@
25 25
26namespace Settings { 26namespace Settings {
27 27
28#ifndef _CANNOT_EXPLICITLY_INSTANTIATE
28#define SETTING(TYPE, RANGED) template class Setting<TYPE, RANGED> 29#define SETTING(TYPE, RANGED) template class Setting<TYPE, RANGED>
29#define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting<TYPE, RANGED> 30#define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting<TYPE, RANGED>
30 31
@@ -61,6 +62,7 @@ SWITCHABLE(u8, true);
61 62
62#undef SETTING 63#undef SETTING
63#undef SWITCHABLE 64#undef SWITCHABLE
65#endif
64 66
65Values values; 67Values values;
66 68
diff --git a/src/common/settings.h b/src/common/settings.h
index e510036b4..35fa4cf3d 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -45,6 +45,7 @@ struct ResolutionScalingInfo {
45 } 45 }
46}; 46};
47 47
48#ifndef _CANNOT_EXPLICITLY_INSTANTIATE
48// Instantiate the classes elsewhere (settings.cpp) to reduce compiler/linker work 49// Instantiate the classes elsewhere (settings.cpp) to reduce compiler/linker work
49#define SETTING(TYPE, RANGED) extern template class Setting<TYPE, RANGED> 50#define SETTING(TYPE, RANGED) extern template class Setting<TYPE, RANGED>
50#define SWITCHABLE(TYPE, RANGED) extern template class SwitchableSetting<TYPE, RANGED> 51#define SWITCHABLE(TYPE, RANGED) extern template class SwitchableSetting<TYPE, RANGED>
@@ -84,6 +85,7 @@ SWITCHABLE(u8, true);
84 85
85#undef SETTING 86#undef SETTING
86#undef SWITCHABLE 87#undef SWITCHABLE
88#endif
87 89
88/** 90/**
89 * The InputSetting class allows for getting a reference to either the global or custom members. 91 * The InputSetting class allows for getting a reference to either the global or custom members.
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index 899b75871..5183aabdf 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -235,6 +235,12 @@ if (WIN32 AND YUZU_CRASH_DUMPS)
235 target_compile_definitions(yuzu PRIVATE -DYUZU_DBGHELP) 235 target_compile_definitions(yuzu PRIVATE -DYUZU_DBGHELP)
236endif() 236endif()
237 237
238if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
239 target_compile_definitions(yuzu PRIVATE
240 $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,15>:_CANNOT_EXPLICITLY_INSTANTIATE>
241 )
242endif()
243
238file(GLOB COMPAT_LIST 244file(GLOB COMPAT_LIST
239 ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.qrc 245 ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.qrc
240 ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.json) 246 ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.json)
diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp
index 2a02a27bc..41e2493b3 100644
--- a/src/yuzu/uisettings.cpp
+++ b/src/yuzu/uisettings.cpp
@@ -3,6 +3,7 @@
3 3
4#include "yuzu/uisettings.h" 4#include "yuzu/uisettings.h"
5 5
6#ifndef _CANNOT_EXPLICITLY_INSTANTIATE
6namespace Settings { 7namespace Settings {
7template class Setting<bool>; 8template class Setting<bool>;
8template class Setting<std::string>; 9template class Setting<std::string>;
@@ -12,6 +13,7 @@ template class Setting<u8, true>;
12template class Setting<u8>; 13template class Setting<u8>;
13template class Setting<unsigned long long>; 14template class Setting<unsigned long long>;
14} // namespace Settings 15} // namespace Settings
16#endif
15 17
16namespace UISettings { 18namespace UISettings {
17 19
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h
index 2152b0b3b..08049f9c4 100644
--- a/src/yuzu/uisettings.h
+++ b/src/yuzu/uisettings.h
@@ -17,6 +17,7 @@
17using Settings::Category; 17using Settings::Category;
18using Settings::Setting; 18using Settings::Setting;
19 19
20#ifndef _CANNOT_EXPLICITLY_INSTANTIATE
20namespace Settings { 21namespace Settings {
21extern template class Setting<bool>; 22extern template class Setting<bool>;
22extern template class Setting<std::string>; 23extern template class Setting<std::string>;
@@ -26,6 +27,7 @@ extern template class Setting<u8, true>;
26extern template class Setting<u8>; 27extern template class Setting<u8>;
27extern template class Setting<unsigned long long>; 28extern template class Setting<unsigned long long>;
28} // namespace Settings 29} // namespace Settings
30#endif
29 31
30namespace UISettings { 32namespace UISettings {
31 33