Fix some warnings

This commit is contained in:
Georg Hagen
2024-10-07 10:02:30 +02:00
parent 45b5fe2c26
commit f60b803bda
5 changed files with 10 additions and 7 deletions

View File

@@ -140,7 +140,7 @@ namespace OpenVulkano
} }
[[deprecated]] [[deprecated]]
static bool IsLittleEndian() static constexpr bool IsLittleEndian()
{ {
constexpr bool isLittleEndian = std::endian::native == std::endian::little; constexpr bool isLittleEndian = std::endian::native == std::endian::little;
return isLittleEndian; return isLittleEndian;

View File

@@ -22,6 +22,8 @@ namespace OpenVulkano
{ {
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wswitch" #pragma clang diagnostic ignored "-Wswitch"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch"
constexpr mode_t GetFileType(std::filesystem::file_type type) constexpr mode_t GetFileType(std::filesystem::file_type type)
{ {
switch (type) switch (type)
@@ -51,6 +53,7 @@ namespace OpenVulkano
} }
return std::filesystem::file_type::unknown; return std::filesystem::file_type::unknown;
} }
#pragma GCC diagnostic pop
#pragma clang diagnostic pop #pragma clang diagnostic pop
template<bool BLOCK_WRITE = false> template<bool BLOCK_WRITE = false>

View File

@@ -25,10 +25,10 @@ namespace OpenVulkano
float maxValue; float maxValue;
bool color, littleEndian; 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) : 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) : 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.color ? "PF" : "Pf") << '\n';
outStream << pfmHeader.width << ' ' << pfmHeader.height << '\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'; outStream << std::fixed << std::setprecision(1) << pfmHeader.maxValue << '\n';
return outStream; return outStream;
} }
@@ -96,7 +96,7 @@ namespace OpenVulkano
inStream >> header; inStream >> header;
size_t size = header.GetElementCount(); size_t size = header.GetElementCount();
if (Utils::IsLittleEndian() != header.littleEndian) if ((std::endian::native == std::endian::little) != header.littleEndian)
{ {
char* data = reinterpret_cast<char*>(image.get()); char* data = reinterpret_cast<char*>(image.get());
for(size_t i = 0; i < size; i++) for(size_t i = 0; i < size; i++)

View File

@@ -50,7 +50,7 @@ namespace OpenVulkano::Math
}; };
}; };
RGB565() : r(0), g(0), b(0) {} RGB565() : value(0) {}
template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true> template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
RGB565(const Math::Vector3<T>& color) : b(Make5(color.b)), g(Make6(color.g)), r(Make5(color.r)) RGB565(const Math::Vector3<T>& color) : b(Make5(color.b)), g(Make6(color.g)), r(Make5(color.r))

View File

@@ -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<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true> template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
RGBA5551(const Math::Vector3<T>& color) : b(Make5(color.b)), g(Make5(color.g)), r(Make5(color.r)), a(1) RGBA5551(const Math::Vector3<T>& color) : b(Make5(color.b)), g(Make5(color.g)), r(Make5(color.r)), a(1)