mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Use stricter C++ compiler flags
Enable more warnings, and treat all warnings as errors. This would have caught the incomplete switch fixed in f5f89be659.
This commit is contained in:
+45
-2
@@ -180,12 +180,55 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_compile_options(loot PRIVATE "-Wall" "-Wextra")
|
||||
target_compile_options(loot PRIVATE
|
||||
"-Werror"
|
||||
"-Wall"
|
||||
"-Wextra"
|
||||
"-Wpedantic"
|
||||
"-Wconversion"
|
||||
"-Wdeprecated"
|
||||
"-Wuninitialized"
|
||||
"-Winit-self"
|
||||
"-Wswitch-enum"
|
||||
"-Wstrict-overflow=5"
|
||||
"-Wstringop-overflow=4"
|
||||
"-Wduplicated-branches"
|
||||
"-Wduplicated-cond"
|
||||
"-Wzero-as-null-pointer-constant"
|
||||
"-Wfloat-equal"
|
||||
"-Wshadow"
|
||||
"-Wcast-qual"
|
||||
"-Wcast-align"
|
||||
"-Wsign-conversion"
|
||||
"-Wlogical-op"
|
||||
"-Wvla"
|
||||
"-Wno-xor-used-as-pow")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# Turn off permissive mode to be more standards-compliant and avoid compiler errors.
|
||||
target_compile_options(loot PRIVATE "/permissive-" "/W4" "/Zc:__cplusplus" "/GL" "/MP")
|
||||
target_compile_options(loot PRIVATE
|
||||
"/permissive-"
|
||||
"/W4"
|
||||
"/Wall"
|
||||
"/WX"
|
||||
"/wd4514"
|
||||
"/wd4623"
|
||||
"/wd4625"
|
||||
"/wd4626"
|
||||
"/wd4710"
|
||||
"/wd4738"
|
||||
"/wd4820"
|
||||
"/wd5026"
|
||||
"/wd5027"
|
||||
"/wd5045"
|
||||
"/external:anglebrackets"
|
||||
"/external:W0"
|
||||
"/Zc:__cplusplus"
|
||||
"/GL"
|
||||
"/MP"
|
||||
"/sdl"
|
||||
"$<$<CONFIG:Debug>:/RTC1>")
|
||||
target_link_options(loot PRIVATE "/LTCG")
|
||||
endif()
|
||||
|
||||
|
||||
+7
-6
@@ -43,8 +43,6 @@ LogLevel convert(uint8_t level) {
|
||||
return LogLevel::info;
|
||||
} else if (level == LIBLOOT_LOG_LEVEL_WARNING) {
|
||||
return LogLevel::warning;
|
||||
} else if (level == LIBLOOT_LOG_LEVEL_ERROR) {
|
||||
return LogLevel::error;
|
||||
} else {
|
||||
return LogLevel::error;
|
||||
}
|
||||
@@ -67,10 +65,13 @@ loot::rust::LogLevel convert(LogLevel level) {
|
||||
}
|
||||
}
|
||||
|
||||
void loggingCallback(uint8_t level, const char* message, void* context) {
|
||||
auto& callback = *static_cast<Callback*>(context);
|
||||
|
||||
callback(convert(level), message);
|
||||
void loggingCallback(uint8_t level, const char* message, void* context) noexcept {
|
||||
try {
|
||||
auto& callback = *static_cast<Callback*>(context);
|
||||
callback(convert(level), message);
|
||||
} catch (...) {
|
||||
// Can't do anything with the exception.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ std::optional<loot::EdgeType> convert(loot::rust::EdgeType edgeType) {
|
||||
return loot::EdgeType::tieBreak;
|
||||
case loot::rust::EdgeType::BlueprintMaster:
|
||||
return loot::EdgeType::blueprintMaster;
|
||||
case loot::rust::EdgeType::None:
|
||||
return std::nullopt;
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace {
|
||||
template<typename T>
|
||||
std::vector<T> mergeVectors(std::vector<T> first,
|
||||
const std::vector<T>& second) {
|
||||
const auto initialSizeOfFirst = first.size();
|
||||
const auto initialSizeOfFirst = first.end() - first.begin();
|
||||
for (const auto& element : second) {
|
||||
const auto end = first.cbegin() + initialSizeOfFirst;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user