More precise C++ features detection

master
Christophe Riccio ago%!(EXTRA string=12 years)
parent 5c84e480bf
commit 08ada74f36
  1. 58
      glm/core/setup.hpp
  2. 4
      glm/core/type_int.hpp
  3. 2
      glm/core/type_vec2.hpp
  4. 2
      glm/core/type_vec3.hpp
  5. 2
      glm/core/type_vec4.hpp
  6. 2
      test/external/gli/core/image2d.inl
  7. 6
      test/gtc/gtc_random.cpp

@ -477,6 +477,43 @@
# endif//GLM_MODEL # endif//GLM_MODEL
#endif//GLM_MESSAGE #endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Has of C++ features
#ifndef __has_feature
# define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
#ifndef __has_extension
# define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
#endif
// http://clang.llvm.org/cxx_status.html
// http://gcc.gnu.org/projects/cxx0x.html
// http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx
// N1720
#define GLM_HAS_STATIC_ASSERT ( \
(GLM_LANG & GLM_LANG_CXX11_FLAG) || \
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2010)) || \
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \
__has_feature(cxx_static_assert))
// N1988
#define GLM_HAS_EXTENDED_INTEGER_TYPE ( \
(GLM_LANG & GLM_LANG_CXX11_FLAG) || \
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012)) || \
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER >= GLM_COMPILER_CLANG29)))
// N2235
#define GLM_HAS_CONSTEXPR ( \
(GLM_LANG & GLM_LANG_CXX11_FLAG) || \
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \
__has_feature(cxx_constexpr))
// Not standard
#define GLM_HAS_ANONYMOUS_UNION (GLM_LANG & GLM_LANG_CXXMS_FLAG)
///////////////// /////////////////
// Platform // Platform
@ -594,7 +631,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Static assert // Static assert
#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X) #if GLM_HAS_STATIC_ASSERT
# define GLM_STATIC_ASSERT(x, message) static_assert(x, message) # define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
#elif(defined(BOOST_STATIC_ASSERT)) #elif(defined(BOOST_STATIC_ASSERT))
# define GLM_STATIC_ASSERT(x, message) BOOST_STATIC_ASSERT(x) # define GLM_STATIC_ASSERT(x, message) BOOST_STATIC_ASSERT(x)
@ -648,7 +685,7 @@
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)) #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED))
# define GLM_MESSAGE_SWIZZLE_DISPLAYED # define GLM_MESSAGE_SWIZZLE_DISPLAYED
# if defined(GLM_SWIZZLE) # if defined(GLM_SWIZZL)E
# pragma message("GLM: Swizzling operators enabled") # pragma message("GLM: Swizzling operators enabled")
# else # else
# pragma message("GLM: Swizzling operators disabled") # pragma message("GLM: Swizzling operators disabled")
@ -664,32 +701,31 @@
# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct # define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
# define GLM_RESTRICT __declspec(restrict) # define GLM_RESTRICT __declspec(restrict)
# define GLM_RESTRICT_VAR __restrict # define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR
#elif(GLM_COMPILER & GLM_COMPILER_INTEL) #elif(GLM_COMPILER & GLM_COMPILER_INTEL)
# define GLM_DEPRECATED # define GLM_DEPRECATED
# define GLM_ALIGN(x) __declspec(align(x)) # define GLM_ALIGN(x) __declspec(align(x))
# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct # define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
# define GLM_RESTRICT # define GLM_RESTRICT
# define GLM_RESTRICT_VAR __restrict # define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR #elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG))
#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC34)) || (GLM_COMPILER & GLM_COMPILER_CLANG))
# define GLM_DEPRECATED __attribute__((__deprecated__)) # define GLM_DEPRECATED __attribute__((__deprecated__))
# define GLM_ALIGN(x) __attribute__((aligned(x))) # define GLM_ALIGN(x) __attribute__((aligned(x)))
# define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x))) # define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
# define GLM_RESTRICT __restrict__ # define GLM_RESTRICT __restrict__
# define GLM_RESTRICT_VAR __restrict__ # define GLM_RESTRICT_VAR __restrict__
# if((GLM_COMPILER >= GLM_COMPILER_GCC47) && ((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X))
# define GLM_CONSTEXPR constexpr
# else
# define GLM_CONSTEXPR
# endif
#else #else
# define GLM_DEPRECATED # define GLM_DEPRECATED
# define GLM_ALIGN # define GLM_ALIGN
# define GLM_ALIGNED_STRUCT(x) # define GLM_ALIGNED_STRUCT(x)
# define GLM_RESTRICT # define GLM_RESTRICT
# define GLM_RESTRICT_VAR # define GLM_RESTRICT_VAR
# define GLM_CONSTEXPR
#endif//GLM_COMPILER #endif//GLM_COMPILER
#if GLM_HAS_CONSTEXPR
# define GLM_CONSTEXPR constexpr
#else
# define GLM_CONSTEXPR
#endif
#endif//GLM_SETUP_INCLUDED #endif//GLM_SETUP_INCLUDED

@ -31,14 +31,14 @@
#include "setup.hpp" #include "setup.hpp"
#if(((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) #if GLM_HAS_EXTENDED_INTEGER_TYPE
# include <cstdint> # include <cstdint>
#endif #endif
namespace glm{ namespace glm{
namespace detail namespace detail
{ {
# if((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) # if GLM_HAS_EXTENDED_INTEGER_TYPE
typedef std::int8_t int8; typedef std::int8_t int8;
typedef std::int16_t int16; typedef std::int16_t int16;
typedef std::int32_t int32; typedef std::int32_t int32;

@ -49,7 +49,7 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Data // Data
# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE)) # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
union union
{ {
struct{ T x, y; }; struct{ T x, y; };

@ -49,7 +49,7 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Data // Data
# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE)) # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
union union
{ {
struct{ T x, y, z; }; struct{ T x, y, z; };

@ -49,7 +49,7 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Data // Data
# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE)) # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
union union
{ {
struct { T r, g, b, a; }; struct { T r, g, b, a; };

@ -96,7 +96,7 @@ namespace gli
}; };
return Desc[Format]; return Desc[Format];
}; }
inline image2D::size_type sizeBlock inline image2D::size_type sizeBlock
( (

@ -11,7 +11,7 @@
#include <glm/gtc/random.hpp> #include <glm/gtc/random.hpp>
#include <glm/gtc/epsilon.hpp> #include <glm/gtc/epsilon.hpp>
#include <iostream> #include <iostream>
#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X) #if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
# include <array> # include <array>
#endif #endif
@ -139,7 +139,7 @@ int test_ballRand()
return Error; return Error;
} }
/* /*
#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X) #if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
int test_grid() int test_grid()
{ {
int Error = 0; int Error = 0;
@ -189,7 +189,7 @@ int main()
Error += test_diskRand(); Error += test_diskRand();
Error += test_ballRand(); Error += test_ballRand();
/* /*
#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X) #if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
Error += test_grid(); Error += test_grid();
#endif #endif
*/ */

Loading…
Cancel
Save