From f60b803bda7824f87e6a9f6ba0eaffaba01cdfe7 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Mon, 7 Oct 2024 10:02:30 +0200 Subject: [PATCH] Fix some warnings --- openVulkanoCpp/Base/Utils.hpp | 2 +- openVulkanoCpp/IO/Archive/LibArchiveHelper.hpp | 3 +++ openVulkanoCpp/IO/Files/Pfm.hpp | 8 ++++---- openVulkanoCpp/Math/RGB565.hpp | 2 +- openVulkanoCpp/Math/RGBA5551.hpp | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/openVulkanoCpp/Base/Utils.hpp b/openVulkanoCpp/Base/Utils.hpp index ecfa490..803995c 100644 --- a/openVulkanoCpp/Base/Utils.hpp +++ b/openVulkanoCpp/Base/Utils.hpp @@ -140,7 +140,7 @@ namespace OpenVulkano } [[deprecated]] - static bool IsLittleEndian() + static constexpr bool IsLittleEndian() { constexpr bool isLittleEndian = std::endian::native == std::endian::little; return isLittleEndian; diff --git a/openVulkanoCpp/IO/Archive/LibArchiveHelper.hpp b/openVulkanoCpp/IO/Archive/LibArchiveHelper.hpp index c4eec60..2e7fee7 100644 --- a/openVulkanoCpp/IO/Archive/LibArchiveHelper.hpp +++ b/openVulkanoCpp/IO/Archive/LibArchiveHelper.hpp @@ -22,6 +22,8 @@ namespace OpenVulkano { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wswitch" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch" constexpr mode_t GetFileType(std::filesystem::file_type type) { switch (type) @@ -51,6 +53,7 @@ namespace OpenVulkano } return std::filesystem::file_type::unknown; } +#pragma GCC diagnostic pop #pragma clang diagnostic pop template diff --git a/openVulkanoCpp/IO/Files/Pfm.hpp b/openVulkanoCpp/IO/Files/Pfm.hpp index 182cfef..3bd44c6 100644 --- a/openVulkanoCpp/IO/Files/Pfm.hpp +++ b/openVulkanoCpp/IO/Files/Pfm.hpp @@ -25,10 +25,10 @@ namespace OpenVulkano float maxValue; bool color, littleEndian; - PfmHeader() : width(0), height(0), maxValue(0), color(false), littleEndian(Utils::IsLittleEndian()) {} + PfmHeader() : width(0), height(0), maxValue(0), color(false), littleEndian(std::endian::native == std::endian::little) {} PfmHeader(uint32_t width, uint32_t height, float maxValue, bool color) : - width(width), height(height), maxValue(maxValue), color(color), littleEndian(Utils::IsLittleEndian()) + width(width), height(height), maxValue(maxValue), color(color), littleEndian(std::endian::native == std::endian::little) {} constexpr PfmHeader(uint32_t width, uint32_t height, float maxValue, bool color, bool littleEndian) : @@ -46,7 +46,7 @@ namespace OpenVulkano { outStream << (pfmHeader.color ? "PF" : "Pf") << '\n'; outStream << pfmHeader.width << ' ' << pfmHeader.height << '\n'; - if (pfmHeader.littleEndian) outStream << '-'; + if constexpr (std::endian::native == std::endian::little) outStream << '-'; outStream << std::fixed << std::setprecision(1) << pfmHeader.maxValue << '\n'; return outStream; } @@ -96,7 +96,7 @@ namespace OpenVulkano inStream >> header; size_t size = header.GetElementCount(); - if (Utils::IsLittleEndian() != header.littleEndian) + if ((std::endian::native == std::endian::little) != header.littleEndian) { char* data = reinterpret_cast(image.get()); for(size_t i = 0; i < size; i++) diff --git a/openVulkanoCpp/Math/RGB565.hpp b/openVulkanoCpp/Math/RGB565.hpp index 4a66454..7b1977e 100644 --- a/openVulkanoCpp/Math/RGB565.hpp +++ b/openVulkanoCpp/Math/RGB565.hpp @@ -50,7 +50,7 @@ namespace OpenVulkano::Math }; }; - RGB565() : r(0), g(0), b(0) {} + RGB565() : value(0) {} template, bool> = true> RGB565(const Math::Vector3& color) : b(Make5(color.b)), g(Make6(color.g)), r(Make5(color.r)) diff --git a/openVulkanoCpp/Math/RGBA5551.hpp b/openVulkanoCpp/Math/RGBA5551.hpp index 97480b6..a0041fb 100644 --- a/openVulkanoCpp/Math/RGBA5551.hpp +++ b/openVulkanoCpp/Math/RGBA5551.hpp @@ -31,7 +31,7 @@ namespace OpenVulkano::Math }; }; - RGBA5551() : r(0), g(0), b(0), a(1) {} + RGBA5551() : b(0), g(0), r(0), a(1) {} template, bool> = true> RGBA5551(const Math::Vector3& color) : b(Make5(color.b)), g(Make5(color.g)), r(Make5(color.r)), a(1)