Skip to content

Commit

Permalink
Visual C++: Enables /Wall
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-lunarg committed Feb 8, 2024
1 parent 4eb3fe1 commit 88a6ed6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
1 change: 1 addition & 0 deletions glm/ext/scalar_ulp.inl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4127)
# pragma warning(disable : 4365) // '=': signed/unsigned mismatch
#elif GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wsign-conversion"
Expand Down
2 changes: 1 addition & 1 deletion glm/gtc/packing.inl
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ namespace detail
detail::u9u9u9e5 Unpack;
Unpack.pack = v;

return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * pow(2.0f, Unpack.data.w - 15.f - 9.f);
return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * pow(2.0f, static_cast<float>(Unpack.data.w) - 15.f - 9.f);
}

// Based on Brian Karis http:https://graphicrants.blogspot.fr/2009/04/rgbm-color-encoding.html
Expand Down
16 changes: 15 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,21 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
endif()

if(NOT GLM_DISABLE_AUTO_DETECTION)
add_compile_options(/W4 /WX)
add_compile_options(/Wall /WX)
add_compile_options(/wd4464) # warning C4464: relative include path contains '..'
add_compile_options(/wd4514) # warning C4514: unreferenced inline function has been removed
add_compile_options(/wd4365) # warning C4365: signed/unsigned mismatch
add_compile_options(/wd5045) # warning C5045: Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
add_compile_options(/wd5029) # warning C5029: nonstandard extension used: alignment attributes in C++ apply to variables, data members and tag types only
add_compile_options(/wd4820) # warning C4820: 'test_decl::S1': '3' bytes padding added after data member 'test_decl::S1::A'
add_compile_options(/wd4710) # warning C4710: 'std::string glm::detail::format(const char *,...)': function not inlined
add_compile_options(/wd4626) # warning C4626: 'glm::io::format_punct<CTy>': assignment operator was implicitly defined as deleted
add_compile_options(/wd4711) # warning C4711: function 'int __cdecl test_vec1(void)' selected for automatic inline expansion
add_compile_options(/wd4571) # warning C4571: Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
add_compile_options(/wd4625) # warning C4625: 'std::codecvt_base': copy constructor was implicitly defined as deleted
add_compile_options(/wd5026) # warning C5026: 'std::_Generic_error_category': move constructor was implicitly defined as deleted
add_compile_options(/wd5027) # warning C5027: 'std::_Generic_error_category': move assignment operator was implicitly defined as deleted
add_compile_options(/wd4774) # warning C4774: 'sprintf_s' : format string expected in argument 3 is not a string literal
endif()
# add_compile_options(/wd4309 /wd4324 /wd4389 /wd4127 /wd4267 /wd4146 /wd4201 /wd4464 /wd4514 /wd4701 /wd4820 /wd4365)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
Expand Down
2 changes: 2 additions & 0 deletions test/core/core_func_integer_bit_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <cstdlib> //To define "exit", req'd by XLC.
#include <ctime>

#include <glm/glm.hpp>

#ifdef NDEBUG

#if GLM_COMPILER & GLM_COMPILER_CLANG
Expand Down
20 changes: 10 additions & 10 deletions test/core/core_func_integer_find_lsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,23 @@ static int ntz7(unsigned x)
// This file has divisions by zero to test isnan
#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4800)
# pragma warning(disable : 4146)
#endif

/*
static int ntz7_christophe(unsigned x)
{
unsigned y, bz, b4, b3, b2, b1, b0;
y = x & -x; // Isolate rightmost 1-bit.
bz = unsigned(!bool(y)); // 1 if y = 0.
b4 = unsigned(!bool(y & 0x0000FFFF)) * 16;
b3 = unsigned(!bool(y & 0x00FF00FF)) * 8;
b2 = unsigned(!bool(y & 0x0F0F0F0F)) * 4;
b1 = unsigned(!bool(y & 0x33333333)) * 2;
b0 = unsigned(!bool(y & 0x55555555)) * 1;
bz = static_cast<unsigned>(!static_cast<bool>(y)); // 1 if y = 0.
b4 = static_cast<unsigned>(!static_cast<bool>(y & 0x0000FFFF)) * 16;
b3 = static_cast<unsigned>(!static_cast<bool>(y & 0x00FF00FF)) * 8;
b2 = static_cast<unsigned>(!static_cast<bool>(y & 0x0F0F0F0F)) * 4;
b1 = static_cast<unsigned>(!static_cast<bool>(y & 0x33333333)) * 2;
b0 = static_cast<unsigned>(!static_cast<bool>(y & 0x55555555)) * 1;
return bz + b4 + b3 + b2 + b1 + b0;
}
*/

/* Below is David Seal's algorithm, found at
http:https://www.ciphersbyritter.com/NEWS4/BITCT.HTM Table
Expand Down Expand Up @@ -386,15 +386,15 @@ int main()
TimestampEnd = std::clock();

std::printf("ntz7: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

/*
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
if (ntz7_christophe(test[i]) != test[i+1]) error(test[i], ntz7(test[i]));}
TimestampEnd = std::clock();
std::printf("ntz7_christophe: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));

*/
TimestampBeg = std::clock();
for (std::size_t k = 0; k < Count; ++k)
for (i = 0; i < n; i += 2) {
Expand Down

0 comments on commit 88a6ed6

Please sign in to comment.