build: Make ImHex fully compile with warnings enabled in MSVC
This commit is contained in:
parent
3a7578879f
commit
e1580e51cf
@ -131,6 +131,7 @@ macro(detectOS)
|
||||
add_compile_definitions(WIN32_LEAN_AND_MEAN)
|
||||
add_compile_definitions(NOMINMAX)
|
||||
add_compile_definitions(UNICODE)
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||
elseif (APPLE)
|
||||
add_compile_definitions(OS_MACOS)
|
||||
set(CMAKE_INSTALL_BINDIR ".")
|
||||
@ -626,7 +627,16 @@ macro(setupDebugCompressionFlag)
|
||||
endmacro()
|
||||
|
||||
macro(setupCompilerFlags target)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
if (IMHEX_STRICT_WARNINGS)
|
||||
addCommonFlag("/W4" ${target})
|
||||
addCommonFlag("/wd4242" ${target})
|
||||
addCommonFlag("/wd4244" ${target})
|
||||
addCommonFlag("/wd4267" ${target})
|
||||
addCommonFlag("/wd4996" ${target})
|
||||
addCommonFlag("/wd4127" ${target})
|
||||
endif()
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
# Define strict compilation flags
|
||||
if (IMHEX_STRICT_WARNINGS)
|
||||
addCommonFlag("-Wall" ${target})
|
||||
|
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
@ -1 +1 @@
|
||||
Subproject commit da45d0c01757322e08e0f8b503082508178a2e8a
|
||||
Subproject commit bc002793b0da4886f89b9bf230dff0d0226d21f3
|
@ -328,7 +328,7 @@ namespace hex {
|
||||
result = defaultValue;
|
||||
|
||||
return result.get<T>();
|
||||
} catch (const nlohmann::json::exception &e) {
|
||||
} catch (const nlohmann::json::exception &) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
@ -400,8 +400,8 @@ namespace hex::gl {
|
||||
|
||||
T Sx, Cx, Sy, Cy, Sz, Cz;
|
||||
Vector<T,3> angles = ypr;
|
||||
if(!radians)
|
||||
angles *= std::numbers::pi / 180;
|
||||
if (!radians)
|
||||
angles *= std::numbers::pi_v<T> / 180;
|
||||
|
||||
Sx = -sin(angles[0]); Cx = cos(angles[0]);
|
||||
Sy = -sin(angles[1]); Cy = cos(angles[1]);
|
||||
@ -814,11 +814,11 @@ namespace hex::gl {
|
||||
|
||||
template<size_t N>
|
||||
void setUniform(std::string_view name, const Vector<float, N> &value) {
|
||||
if (N == 2)
|
||||
if constexpr (N == 2)
|
||||
glUniform2f(getUniformLocation(name), value[0], value[1]);
|
||||
else if (N == 3)
|
||||
else if constexpr (N == 3)
|
||||
glUniform3f(getUniformLocation(name), value[0], value[1], value[2]);
|
||||
else if (N == 4)
|
||||
else if constexpr (N == 4)
|
||||
glUniform4f(getUniformLocation(name), value[0], value[1], value[2],value[3]);
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ namespace hex {
|
||||
|
||||
std::string result;
|
||||
for (i16 bit = hex::bit_width(number) - 1; bit >= 0; bit -= 1)
|
||||
result += (number & (0b1 << bit)) == 0 ? '0' : '1';
|
||||
result += (number & (0b1LLU << bit)) == 0 ? '0' : '1';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <windows.h>
|
||||
#define PLUGIN_ENTRY_POINT extern "C" BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fwdReason, LPVOID lpReserved) { return TRUE; }
|
||||
#define PLUGIN_ENTRY_POINT extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID) { return TRUE; }
|
||||
#else
|
||||
#define PLUGIN_ENTRY_POINT
|
||||
#endif
|
||||
|
@ -170,7 +170,7 @@ namespace hex::gl {
|
||||
m_buffer = other.m_buffer;
|
||||
m_size = other.m_size;
|
||||
m_type = other.m_type;
|
||||
other.m_buffer = -1;
|
||||
other.m_buffer = 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -178,7 +178,7 @@ namespace hex::gl {
|
||||
m_buffer = other.m_buffer;
|
||||
m_size = other.m_size;
|
||||
m_type = other.m_type;
|
||||
other.m_buffer = -1;
|
||||
other.m_buffer = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -231,12 +231,12 @@ namespace hex::gl {
|
||||
|
||||
VertexArray::VertexArray(VertexArray &&other) noexcept {
|
||||
m_array = other.m_array;
|
||||
other.m_array = -1;
|
||||
other.m_array = 0;
|
||||
}
|
||||
|
||||
VertexArray& VertexArray::operator=(VertexArray &&other) noexcept {
|
||||
m_array = other.m_array;
|
||||
other.m_array = -1;
|
||||
other.m_array = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ namespace hex::gl {
|
||||
|
||||
Texture::Texture(Texture &&other) noexcept {
|
||||
m_texture = other.m_texture;
|
||||
other.m_texture = -1;
|
||||
other.m_texture = 0;
|
||||
|
||||
m_width = other.m_width;
|
||||
m_height = other.m_height;
|
||||
@ -276,7 +276,7 @@ namespace hex::gl {
|
||||
|
||||
Texture& Texture::operator=(Texture &&other) noexcept {
|
||||
m_texture = other.m_texture;
|
||||
other.m_texture = -1;
|
||||
other.m_texture = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ namespace hex::gl {
|
||||
|
||||
GLuint Texture::release() {
|
||||
auto copy = m_texture;
|
||||
m_texture = -1;
|
||||
m_texture = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
@ -327,16 +327,16 @@ namespace hex::gl {
|
||||
|
||||
FrameBuffer::FrameBuffer(FrameBuffer &&other) noexcept {
|
||||
m_frameBuffer = other.m_frameBuffer;
|
||||
other.m_frameBuffer = -1;
|
||||
other.m_frameBuffer = 0;
|
||||
m_renderBuffer = other.m_renderBuffer;
|
||||
other.m_renderBuffer = -1;
|
||||
other.m_renderBuffer = 0;
|
||||
}
|
||||
|
||||
FrameBuffer& FrameBuffer::operator=(FrameBuffer &&other) noexcept {
|
||||
m_frameBuffer = other.m_frameBuffer;
|
||||
other.m_frameBuffer = -1;
|
||||
other.m_frameBuffer = 0;
|
||||
m_renderBuffer = other.m_renderBuffer;
|
||||
other.m_renderBuffer = -1;
|
||||
other.m_renderBuffer = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -667,10 +667,8 @@ namespace ImGuiExt {
|
||||
}
|
||||
|
||||
ImVec2 GetCustomStyleVec2(ImGuiCustomStyle idx) {
|
||||
switch (idx) {
|
||||
default:
|
||||
return { };
|
||||
}
|
||||
std::ignore = idx;
|
||||
return {};
|
||||
}
|
||||
|
||||
void StyleCustomColorsDark() {
|
||||
@ -859,7 +857,7 @@ namespace ImGuiExt {
|
||||
: ImGuiCol_Button);
|
||||
RenderNavCursor(bb, id);
|
||||
RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
|
||||
RenderTextClipped(bb.Min + style.FramePadding * ImVec2(1.3, 1) + iconOffset, bb.Max - style.FramePadding, symbol, nullptr, &label_size, style.ButtonTextAlign, &bb);
|
||||
RenderTextClipped(bb.Min + style.FramePadding * ImVec2(1.3F, 1) + iconOffset, bb.Max - style.FramePadding, symbol, nullptr, &label_size, style.ButtonTextAlign, &bb);
|
||||
|
||||
PopStyleColor();
|
||||
|
||||
|
2
lib/third_party/yara/CMakeLists.txt
vendored
2
lib/third_party/yara/CMakeLists.txt
vendored
@ -117,6 +117,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(libyara PRIVATE -Wno-shift-count-overflow -Wno-stringop-overflow)
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_compile_options(libyara PRIVATE -Wno-pointer-sign -Wno-tautological-constant-out-of-range-compare)
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_compile_options(libyara PRIVATE /wd4005)
|
||||
endif ()
|
||||
|
||||
target_include_directories(
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <wolv/io/fs.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <array>
|
||||
|
||||
void setupConsoleWindow() {
|
||||
// Get the handle of the console window
|
||||
|
@ -283,7 +283,7 @@ namespace hex::init {
|
||||
const auto highlightBytes = [&](ImVec2 start, size_t count, ImColor color, float opacity) {
|
||||
// Dimensions and number of bytes that are drawn. Taken from the splash screen image
|
||||
const auto hexSize = ImVec2(29, 18);
|
||||
const auto hexSpacing = ImVec2(17.4, 15);
|
||||
const auto hexSpacing = ImVec2(17.4F, 15);
|
||||
const auto hexStart = ImVec2(27, 127);
|
||||
|
||||
constexpr auto HexCount = ImVec2(13, 7);
|
||||
|
@ -406,7 +406,7 @@ namespace hex {
|
||||
ImGuiExt::UnderlinedText("Plugin folders");
|
||||
if (ImGui::BeginTable("plugins", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY | ImGuiTableFlags_SizingFixedFit, ImVec2(0, 100_scaled))) {
|
||||
ImGui::TableSetupScrollFreeze(0, 1);
|
||||
ImGui::TableSetupColumn("Path", ImGuiTableColumnFlags_WidthStretch, 0.2);
|
||||
ImGui::TableSetupColumn("Path", ImGuiTableColumnFlags_WidthStretch, 0.2F);
|
||||
ImGui::TableSetupColumn("Exists", ImGuiTableColumnFlags_WidthFixed, ImGui::GetTextLineHeight() * 3);
|
||||
|
||||
ImGui::TableHeadersRow();
|
||||
@ -649,7 +649,7 @@ namespace hex {
|
||||
auto prevShadowOffset = style.WindowShadowOffsetDist;
|
||||
auto prevShadowAngle = style.WindowShadowOffsetAngle;
|
||||
style.WindowShadowOffsetDist = 12_scaled;
|
||||
style.WindowShadowOffsetAngle = 0.5 * std::numbers::pi;
|
||||
style.WindowShadowOffsetAngle = 0.5F * std::numbers::pi_v<float>;
|
||||
ON_SCOPE_EXIT {
|
||||
style.WindowShadowOffsetDist = prevShadowOffset;
|
||||
style.WindowShadowOffsetAngle = prevShadowAngle;
|
||||
|
@ -91,7 +91,7 @@ namespace hex::plugin::builtin {
|
||||
T value = 0x00;
|
||||
std::memcpy(&value, buffer.data(), std::min(sizeof(T), Size));
|
||||
value = hex::changeEndianness(value, Size, endian);
|
||||
if (Size != sizeof(T))
|
||||
if constexpr (Size != sizeof(T))
|
||||
value = T(hex::signExtend(Size * 8, value));
|
||||
|
||||
return value;
|
||||
|
@ -23,8 +23,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void drawNode() override {
|
||||
ImGui::PushItemWidth(100_scaled);
|
||||
ImGui::Combo("hex.builtin.nodes.crypto.aes.mode"_lang, &m_mode, "ECB\0CBC\0CFB128\0CTR\0GCM\0CCM\0OFB\0");
|
||||
ImGui::Combo("hex.builtin.nodes.crypto.aes.key_length"_lang, &m_keyLength, "128 Bits\000192 Bits\000256 Bits\000");
|
||||
ImGui::Combo("hex.builtin.nodes.crypto.aes.mode"_lang, &m_mode, "ECB\x00""CBC\x00""CFB128\x00""CTR\x00""GCM\x00""CCM\x00""OFB\x00");
|
||||
ImGui::Combo("hex.builtin.nodes.crypto.aes.key_length"_lang, &m_keyLength, "128 Bits\x00""192 Bits\x00""256 Bits\x00");
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ namespace hex::plugin::builtin {
|
||||
private:
|
||||
std::vector<u8> m_data;
|
||||
ImGuiExt::Texture m_texture;
|
||||
u32 m_width, m_height;
|
||||
u32 m_width = 0, m_height = 0;
|
||||
};
|
||||
|
||||
class NodeVisualizerByteDistribution : public dp::Node {
|
||||
|
@ -375,7 +375,7 @@ namespace hex::plugin::builtin {
|
||||
if (inputType == InputType::Regular) {
|
||||
try {
|
||||
ieee754statics.resultFloat = stod(decimalFloatingPointNumberString);
|
||||
} catch(const std::invalid_argument& _) {
|
||||
} catch (const std::invalid_argument &) {
|
||||
inputType = InputType::Invalid;
|
||||
}
|
||||
} else if (inputType == InputType::Infinity) {
|
||||
|
@ -106,8 +106,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (ImGui::BeginTable("##mathWrapper", 3)) {
|
||||
ImGui::TableSetupColumn("##keypad", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableSetupColumn("##results", ImGuiTableColumnFlags_WidthStretch, 0.666);
|
||||
ImGui::TableSetupColumn("##variables", ImGuiTableColumnFlags_WidthStretch, 0.666);
|
||||
ImGui::TableSetupColumn("##results", ImGuiTableColumnFlags_WidthStretch, 0.666F);
|
||||
ImGui::TableSetupColumn("##variables", ImGuiTableColumnFlags_WidthStretch, 0.666F);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
@ -179,7 +179,7 @@ namespace hex::plugin::builtin {
|
||||
// Draw background
|
||||
{
|
||||
const ImVec2 margin = scaled({ 15, 15 });
|
||||
drawList->AddRectFilled(windowPos, windowPos + windowSize, ImGui::GetColorU32(ImGuiCol_WindowBg, 200.0/255.0));
|
||||
drawList->AddRectFilled(windowPos, windowPos + windowSize, ImGui::GetColorU32(ImGuiCol_WindowBg, 200.0F / 255.0F));
|
||||
drawList->AddRect(windowPos + margin, (windowPos + windowSize) - margin, ImGuiExt::GetCustomColorU32(ImGuiCustomCol_Highlight), 10_scaled, ImDrawFlags_None, 7.5_scaled);
|
||||
}
|
||||
|
||||
|
@ -490,9 +490,9 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::Begin("ImHexDockSpace", nullptr, ImGuiWindowFlags_NoBringToFrontOnFocus)) {
|
||||
if (!ImHexApi::Provider::isValid()) {
|
||||
static auto title = []{
|
||||
std::array<char, 256> title = {};
|
||||
ImFormatString(title.data(), title.size(), "%s/DockSpace_%08X", ImGui::GetCurrentWindowRead()->Name, ImGui::GetID("ImHexMainDock"));
|
||||
return title;
|
||||
std::array<char, 256> result = {};
|
||||
ImFormatString(result.data(), result.size(), "%s/DockSpace_%08X", ImGui::GetCurrentWindowRead()->Name, ImGui::GetID("ImHexMainDock"));
|
||||
return result;
|
||||
}();
|
||||
|
||||
if (ImGui::Begin(title.data(), nullptr, ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoBringToFrontOnFocus)) {
|
||||
|
@ -8,6 +8,9 @@ else()
|
||||
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/edlib ${CMAKE_CURRENT_BINARY_DIR}/edlib EXCLUDE_FROM_ALL)
|
||||
enableUnityBuild(edlib)
|
||||
if (MSVC)
|
||||
target_compile_options(edlib PRIVATE /wd4244)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
add_imhex_plugin(
|
||||
|
@ -204,7 +204,7 @@ namespace hex::plugin::diffing {
|
||||
|
||||
const auto availableSize = ImGui::GetContentRegionAvail();
|
||||
auto diffingColumnSize = availableSize;
|
||||
diffingColumnSize.y *= 3.5 / 5.0;
|
||||
diffingColumnSize.y *= 3.5F / 5.0F;
|
||||
diffingColumnSize.y -= ImGui::GetTextLineHeightWithSpacing();
|
||||
diffingColumnSize.y += height;
|
||||
|
||||
|
@ -10,6 +10,8 @@ if (NOT USE_SYSTEM_CAPSTONE)
|
||||
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/capstone ${CMAKE_CURRENT_BINARY_DIR}/capstone EXCLUDE_FROM_ALL)
|
||||
if (NOT MSVC)
|
||||
target_compile_options(capstone PRIVATE -Wno-unused-function)
|
||||
else()
|
||||
target_compile_options(capstone PRIVATE /wd4005)
|
||||
endif()
|
||||
set(CAPSTONE_LIBRARY "capstone")
|
||||
set(CAPSTONE_INCLUDE_DIR ${THIRD_PARTY_LIBS_FOLDER}/capstone/include)
|
||||
|
@ -304,6 +304,9 @@ namespace hex::ui {
|
||||
|
||||
|
||||
void HexEditor::drawCell(u64 address, u8 *data, size_t size, bool hovered, CellType cellType) {
|
||||
ImGui::PushID(address + 1);
|
||||
ON_SCOPE_EXIT { ImGui::PopID(); };
|
||||
|
||||
static DataVisualizerAscii asciiVisualizer;
|
||||
|
||||
if (m_shouldUpdateEditingValue && address == m_editingAddress) {
|
||||
|
@ -83,8 +83,8 @@ namespace hex::plugin::visualizers {
|
||||
// Draw clock sections and numbers
|
||||
for (u8 i = 0; i < 12; ++i) {
|
||||
auto text = hex::format("{}", (((i + 2) % 12) + 1));
|
||||
drawList->AddLine(center + sectionPos(i) * size / 2.2, center + sectionPos(i) * size / 2, ImGui::GetColorU32(ImGuiCol_TextDisabled), 1_scaled);
|
||||
drawList->AddText(center + sectionPos(i) * size / 3 - ImGui::CalcTextSize(text.c_str()) / 2, ImGui::GetColorU32(ImGuiCol_Text), text.c_str());
|
||||
drawList->AddLine(center + sectionPos(i) * size / 2.2F, center + sectionPos(i) * size / 2, ImGui::GetColorU32(ImGuiCol_TextDisabled), 1_scaled);
|
||||
drawList->AddText(center + sectionPos(i) * size / 3.0F - ImGui::CalcTextSize(text.c_str()) / 2, ImGui::GetColorU32(ImGuiCol_Text), text.c_str());
|
||||
}
|
||||
|
||||
// Draw hour hand
|
||||
|
@ -5,6 +5,9 @@ include(ImHexPlugin)
|
||||
if (NOT USE_SYSTEM_YARA)
|
||||
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/yara ${CMAKE_CURRENT_BINARY_DIR}/yara EXCLUDE_FROM_ALL)
|
||||
set(YARA_LIBRARIES libyara)
|
||||
if (MSVC)
|
||||
target_compile_options(capstone PRIVATE /wd4005)
|
||||
endif ()
|
||||
else()
|
||||
find_package(Yara REQUIRED)
|
||||
endif()
|
||||
|
@ -9,12 +9,17 @@
|
||||
#if !defined(_MSC_VER)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#else
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4324)
|
||||
#endif
|
||||
|
||||
#include <yara.h>
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
#pragma GCC diagnostic pop
|
||||
#else
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
namespace hex::plugin::yara {
|
||||
|
Loading…
x
Reference in New Issue
Block a user