Chore: Enable warnings as errors on MSVC (#6456)
* tests: add Sanity test for SplitFilename83 fix test fix test * disable `C4715:not all control paths return a value` for nihstro includes nihstro: no warn * Chore: Enable warnings as errors on msvc + fix warnings fixes some more warnings clang-format * more fixes * Externals: Add target_compile_options `/W0` nihstro-headers and ... Revert "disable `C4715:not all control paths return a value` for nihstro includes" This reverts commit 606d79b55d3044b744fb835025b8eb0f4ea5b757. * src\citra\config.cpp: ReadSetting: simplify type casting * settings.cpp: Get*Name: remove superflous logs
This commit is contained in:
parent
055a58f01e
commit
41f13456c0
71 changed files with 397 additions and 294 deletions
|
@ -131,6 +131,25 @@ add_library(citra_common STATIC
|
|||
zstd_compression.h
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
target_compile_definitions(citra_common PRIVATE
|
||||
# The standard library doesn't provide any replacement for codecvt yet
|
||||
# so we can disable this deprecation warning for the time being.
|
||||
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
|
||||
)
|
||||
target_compile_options(citra_common PRIVATE
|
||||
/W4
|
||||
|
||||
/we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data
|
||||
/we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
|
||||
/we4800 # Implicit conversion from 'type' to bool. Possible information loss
|
||||
)
|
||||
else()
|
||||
target_compile_options(citra_common PRIVATE
|
||||
$<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation>
|
||||
)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(citra_common)
|
||||
|
||||
target_link_libraries(citra_common PUBLIC fmt::fmt microprofile Boost::boost Boost::serialization Boost::iostreams)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#define ASSERT(_a_) \
|
||||
do \
|
||||
if (!(_a_)) [[unlikely]] { \
|
||||
[]() CITRA_NO_INLINE { \
|
||||
[]() CITRA_NO_INLINE CITRA_NO_RETURN { \
|
||||
LOG_CRITICAL(Debug, "Assertion Failed!"); \
|
||||
Crash(); \
|
||||
exit(1); \
|
||||
|
@ -26,7 +26,7 @@
|
|||
#define ASSERT_MSG(_a_, ...) \
|
||||
do \
|
||||
if (!(_a_)) [[unlikely]] { \
|
||||
[&]() CITRA_NO_INLINE { \
|
||||
[&]() CITRA_NO_INLINE CITRA_NO_RETURN { \
|
||||
LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); \
|
||||
Crash(); \
|
||||
exit(1); \
|
||||
|
@ -35,14 +35,14 @@
|
|||
while (0)
|
||||
|
||||
#define UNREACHABLE() \
|
||||
([]() CITRA_NO_INLINE { \
|
||||
([]() CITRA_NO_INLINE CITRA_NO_RETURN { \
|
||||
LOG_CRITICAL(Debug, "Unreachable code!"); \
|
||||
Crash(); \
|
||||
exit(1); \
|
||||
}())
|
||||
|
||||
#define UNREACHABLE_MSG(...) \
|
||||
([&]() CITRA_NO_INLINE { \
|
||||
([&]() CITRA_NO_INLINE CITRA_NO_RETURN { \
|
||||
LOG_CRITICAL(Debug, "Unreachable code!\n" __VA_ARGS__); \
|
||||
Crash(); \
|
||||
exit(1); \
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
#define CITRA_NO_INLINE __attribute__((noinline))
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define CITRA_NO_RETURN __declspec(noreturn)
|
||||
#else
|
||||
#define CITRA_NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
extern "C" {
|
||||
__declspec(dllimport) void __stdcall DebugBreak(void);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "common/common_paths.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/string_util.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -540,7 +541,8 @@ void GetAllFilesFromNestedEntries(FSTEntry& directory, std::vector<FSTEntry>& ou
|
|||
}
|
||||
|
||||
bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) {
|
||||
const auto callback = [recursion](u64* num_entries_out, const std::string& directory,
|
||||
const auto callback = [recursion]([[maybe_unused]] u64* num_entries_out,
|
||||
const std::string& directory,
|
||||
const std::string& virtual_name) -> bool {
|
||||
std::string new_path = directory + DIR_SEP_CHR + virtual_name;
|
||||
|
||||
|
@ -560,7 +562,8 @@ bool DeleteDirRecursively(const std::string& directory, unsigned int recursion)
|
|||
return true;
|
||||
}
|
||||
|
||||
void CopyDir(const std::string& source_path, const std::string& dest_path) {
|
||||
void CopyDir([[maybe_unused]] const std::string& source_path,
|
||||
[[maybe_unused]] const std::string& dest_path) {
|
||||
#ifndef _WIN32
|
||||
if (source_path == dest_path)
|
||||
return;
|
||||
|
@ -900,14 +903,14 @@ void SplitFilename83(const std::string& filename, std::array<char, 9>& short_nam
|
|||
short_name[7] = '1';
|
||||
break;
|
||||
}
|
||||
short_name[j++] = toupper(letter);
|
||||
short_name[j++] = Common::ToUpper(letter);
|
||||
}
|
||||
|
||||
// Get extension.
|
||||
if (point != std::string::npos) {
|
||||
j = 0;
|
||||
for (char letter : filename.substr(point + 1, 3))
|
||||
extension[j++] = toupper(letter);
|
||||
extension[j++] = Common::ToUpper(letter);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -259,10 +259,10 @@ const char* GetLogClassName(Class log_class) {
|
|||
#undef CLS
|
||||
#undef SUB
|
||||
case Class::Count:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
UNREACHABLE();
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
const char* GetLevelName(Level log_level) {
|
||||
|
@ -277,11 +277,11 @@ const char* GetLevelName(Level log_level) {
|
|||
LVL(Error);
|
||||
LVL(Critical);
|
||||
case Level::Count:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#undef LVL
|
||||
UNREACHABLE();
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
void AddBackend(std::unique_ptr<Backend> backend) {
|
||||
|
|
|
@ -111,7 +111,7 @@ void PrintColoredMessage(const Entry& entry) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void PrintMessageToLogcat(const Entry& entry) {
|
||||
void PrintMessageToLogcat([[maybe_unused]] const Entry& entry) {
|
||||
#ifdef ANDROID
|
||||
const auto str = FormatLogMessage(entry);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
private:
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int) {}
|
||||
void serialize(Archive&, const unsigned int) {}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,10 @@ std::string_view GetAudioEmulationName(AudioEmulation emulation) {
|
|||
return "LLE";
|
||||
case AudioEmulation::LLEMultithreaded:
|
||||
return "LLE Multithreaded";
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
UNREACHABLE();
|
||||
};
|
||||
|
||||
std::string_view GetGraphicsAPIName(GraphicsAPI api) {
|
||||
|
@ -39,7 +42,10 @@ std::string_view GetGraphicsAPIName(GraphicsAPI api) {
|
|||
return "Software";
|
||||
case GraphicsAPI::OpenGL:
|
||||
return "OpenGL";
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
std::string_view GetTextureFilterName(TextureFilter filter) {
|
||||
|
@ -56,7 +62,10 @@ std::string_view GetTextureFilterName(TextureFilter filter) {
|
|||
return "ScaleForce";
|
||||
case TextureFilter::xBRZ:
|
||||
return "xBRZ";
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
|
|
@ -453,9 +453,9 @@ struct Values {
|
|||
Setting<u16> custom_bottom_bottom{480, "custom_bottom_bottom"};
|
||||
Setting<u16> custom_second_layer_opacity{100, "custom_second_layer_opacity"};
|
||||
|
||||
SwitchableSetting<double> bg_red{0.f, "bg_red"};
|
||||
SwitchableSetting<double> bg_green{0.f, "bg_green"};
|
||||
SwitchableSetting<double> bg_blue{0.f, "bg_blue"};
|
||||
SwitchableSetting<float> bg_red{0.f, "bg_red"};
|
||||
SwitchableSetting<float> bg_green{0.f, "bg_green"};
|
||||
SwitchableSetting<float> bg_blue{0.f, "bg_blue"};
|
||||
|
||||
SwitchableSetting<StereoRenderOption> render_3d{StereoRenderOption::Off, "render_3d"};
|
||||
SwitchableSetting<u32> factor_3d{0, "factor_3d"};
|
||||
|
|
|
@ -20,17 +20,27 @@
|
|||
|
||||
namespace Common {
|
||||
|
||||
/// Make a char lowercase
|
||||
char ToLower(char c) {
|
||||
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
}
|
||||
|
||||
/// Make a char uppercase
|
||||
char ToUpper(char c) {
|
||||
return static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
|
||||
}
|
||||
|
||||
/// Make a string lowercase
|
||||
std::string ToLower(std::string str) {
|
||||
std::transform(str.begin(), str.end(), str.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||
return str;
|
||||
}
|
||||
|
||||
/// Make a string uppercase
|
||||
std::string ToUpper(std::string str) {
|
||||
std::transform(str.begin(), str.end(), str.begin(),
|
||||
[](unsigned char c) { return std::toupper(c); });
|
||||
[](unsigned char c) { return static_cast<char>(std::toupper(c)); });
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
|
||||
namespace Common {
|
||||
|
||||
/// Make a char lowercase
|
||||
[[nodiscard]] char ToLower(char c);
|
||||
|
||||
/// Make a char uppercase
|
||||
[[nodiscard]] char ToUpper(char c);
|
||||
|
||||
/// Make a string lowercase
|
||||
[[nodiscard]] std::string ToLower(std::string str);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue