Skip to content

Commit

Permalink
Disable warnings by default
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-lunarg committed Jan 9, 2024
1 parent ec79055 commit aa14169
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 23 deletions.
6 changes: 3 additions & 3 deletions glm/detail/setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,10 @@ namespace detail
///////////////////////////////////////////////////////////////////////////////////
// Silent warnings

#ifdef GLM_FORCE_SILENT_WARNINGS
# define GLM_SILENT_WARNINGS GLM_ENABLE
#else
#ifdef GLM_FORCE_WARNINGS
# define GLM_SILENT_WARNINGS GLM_DISABLE
#else
# define GLM_SILENT_WARNINGS GLM_ENABLE
#endif

///////////////////////////////////////////////////////////////////////////////////
Expand Down
40 changes: 20 additions & 20 deletions glm/detail/type_quat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@

namespace glm
{
template<typename T, qualifier Q>
struct qua
{
// -- Implementation detail --

typedef qua<T, Q> type;
typedef T value_type;

// -- Data --

# if GLM_SILENT_WARNINGS == GLM_ENABLE
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push
Expand All @@ -39,6 +29,16 @@ namespace glm
# endif
# endif

template<typename T, qualifier Q>
struct qua
{
// -- Implementation detail --

typedef qua<T, Q> type;
typedef T value_type;

// -- Data --

# if GLM_LANG & GLM_LANG_CXXMS_FLAG
union
{
Expand All @@ -56,16 +56,6 @@ namespace glm
# else
T x, y, z, w;
# endif
# endif

# if GLM_SILENT_WARNINGS == GLM_ENABLE
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# elif GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# elif GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif
# endif

// -- Component accesses --
Expand Down Expand Up @@ -139,6 +129,16 @@ namespace glm
GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q>& operator/=(U s);
};

# if GLM_SILENT_WARNINGS == GLM_ENABLE
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# elif GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# elif GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif
# endif

// -- Unary bit operators --

template<typename T, qualifier Q>
Expand Down
6 changes: 6 additions & 0 deletions glm/ext/scalar_ulp.inl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#if(GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(push)
# pragma warning(disable : 4127)
#elif GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wsign-conversion"
# pragma clang diagnostic ignored "-Wpadded"
#endif

typedef union
Expand Down Expand Up @@ -184,6 +188,8 @@ namespace detail

#if(GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(pop)
#elif GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
#endif

namespace glm
Expand Down
24 changes: 24 additions & 0 deletions test/core/core_force_compiler_unknown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,33 @@
# define GLM_FORCE_COMPILER_UNKNOWN
#endif

#if GLM_SILENT_WARNINGS == GLM_ENABLE
# if defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
# pragma clang diagnostic ignored "-Wnested-anon-types"
# elif defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union
# endif
#endif

#include <glm/glm.hpp>
#include <glm/ext.hpp>

#if GLM_SILENT_WARNINGS == GLM_ENABLE
# if defined(__clang__)
# pragma clang diagnostic pop
# elif defined(__GNUC__)
# pragma GCC diagnostic pop
# elif defined(_MSC_VER)
# pragma warning(pop)
# endif
#endif

int main()
{
int Error = 0;
Expand Down
27 changes: 27 additions & 0 deletions test/gtc/gtc_integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ namespace log2_

std::clock_t Begin = clock();

#if GLM_COMPILER& GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable: 4267)
#endif

for(std::size_t i = 0; i < Count; ++i)
{
glm::vec<4, unsigned long, glm::defaultp> Tmp;
Expand All @@ -102,6 +107,10 @@ namespace log2_
Result[i] = glm::ivec4(Tmp);
}

#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
#endif

std::clock_t End = clock();

std::printf("glm::log2<ivec4> inlined: %d clocks\n", static_cast<int>(End - Begin));
Expand All @@ -114,6 +123,11 @@ namespace log2_

std::clock_t Begin = clock();

#if GLM_COMPILER& GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable: 4267)
#endif

for(std::size_t i = 0; i < Count; ++i)
{
_BitScanReverse(&Result[i].x, i);
Expand All @@ -122,6 +136,10 @@ namespace log2_
_BitScanReverse(&Result[i].w, i);
}

#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
#endif

std::clock_t End = clock();

std::printf("glm::log2<ivec4> inlined no cast: %d clocks\n", static_cast<int>(End - Begin));
Expand All @@ -134,6 +152,11 @@ namespace log2_

std::clock_t Begin = clock();

#if GLM_COMPILER& GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable: 4267)
#endif

for(std::size_t i = 0; i < Count; ++i)
{
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].x), i);
Expand All @@ -142,6 +165,10 @@ namespace log2_
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].w), i);
}

#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
#endif

std::clock_t End = clock();

std::printf("glm::log2<ivec4> reinterpret: %d clocks\n", static_cast<int>(End - Begin));
Expand Down

0 comments on commit aa14169

Please sign in to comment.