diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index 814cf4d33..38b4f4866 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -1145,19 +1145,39 @@ template struct SizedVectorAttribute { }; template<> struct SizedAttribute<1, 1>: SizedVectorAttribute<1> { enum class Components: GLint { One = 1 }; - constexpr static Components DefaultComponents = Components::One; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + Components DefaultComponents = Components::One; }; template<> struct SizedAttribute<1, 2>: SizedVectorAttribute<1> { enum class Components: GLint { One = 1, Two = 2 }; - constexpr static Components DefaultComponents = Components::Two; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + Components DefaultComponents = Components::Two; }; template<> struct SizedAttribute<1, 3>: SizedVectorAttribute<1> { enum class Components: GLint { One = 1, Two = 2, Three = 3 }; - constexpr static Components DefaultComponents = Components::Three; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + Components DefaultComponents = Components::Three; }; template<> struct SizedAttribute<1, 4>: SizedVectorAttribute<1> { enum class Components: GLint { One = 1, Two = 2, Three = 3, Four = 4 }; - constexpr static Components DefaultComponents = Components::Four; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + Components DefaultComponents = Components::Four; }; Debug MAGNUM_EXPORT operator<<(Debug debug, SizedAttribute<1, 1>::Components value); Debug MAGNUM_EXPORT operator<<(Debug debug, SizedAttribute<1, 2>::Components value); @@ -1168,15 +1188,30 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, SizedAttribute<1, 4>::Components val template struct SizedMatrixAttribute; template<> struct SizedMatrixAttribute<2> { enum class Components: GLint { Two = 2 }; - constexpr static Components DefaultComponents = Components::Two; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + Components DefaultComponents = Components::Two; }; template<> struct SizedMatrixAttribute<3> { enum class Components: GLint { Three = 3 }; - constexpr static Components DefaultComponents = Components::Three; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + Components DefaultComponents = Components::Three; }; template<> struct SizedMatrixAttribute<4> { enum class Components: GLint { Four = 4 }; - constexpr static Components DefaultComponents = Components::Four; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + Components DefaultComponents = Components::Four; }; Debug MAGNUM_EXPORT operator<<(Debug debug, SizedMatrixAttribute<2>::Components value); Debug MAGNUM_EXPORT operator<<(Debug debug, SizedMatrixAttribute<3>::Components value); @@ -1219,7 +1254,12 @@ struct FloatAttribute { Double = GL_DOUBLE #endif }; - constexpr static DataType DefaultDataType = DataType::Float; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + DataType DefaultDataType = DataType::Float; enum class DataOption: UnsignedByte { Normalized = 1 << 0 @@ -1246,7 +1286,12 @@ struct IntAttribute { UnsignedInt = GL_UNSIGNED_INT, Int = GL_INT }; - constexpr static DataType DefaultDataType = DataType::Int; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + DataType DefaultDataType = DataType::Int; enum class DataOption: UnsignedByte {}; typedef Corrade::Containers::EnumSet DataOptions; @@ -1261,7 +1306,12 @@ struct UnsignedIntAttribute { typedef UnsignedInt Type; typedef IntAttribute::DataType DataType; - constexpr static DataType DefaultDataType = DataType::UnsignedInt; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + DataType DefaultDataType = DataType::UnsignedInt; typedef IntAttribute::DataOption DataOption; typedef Corrade::Containers::EnumSet DataOptions; @@ -1280,7 +1330,12 @@ struct DoubleAttribute { enum class DataType: GLenum { Double = GL_DOUBLE }; - constexpr static DataType DefaultDataType = DataType::Double; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + DataType DefaultDataType = DataType::Double; enum class DataOption: UnsignedByte {}; typedef Corrade::Containers::EnumSet DataOptions; @@ -1305,7 +1360,12 @@ template<> struct Attribute> { BGRA = GL_BGRA #endif }; - constexpr static Components DefaultComponents = Components::Four; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + Components DefaultComponents = Components::Four; enum class DataType: GLenum { UnsignedByte = GL_UNSIGNED_BYTE, @@ -1330,7 +1390,12 @@ template<> struct Attribute> { Int2101010Rev = GL_INT_2_10_10_10_REV #endif }; - constexpr static DataType DefaultDataType = DataType::Float; + #ifndef CORRADE_GCC45_COMPATIBILITY + constexpr static + #else + static const + #endif + DataType DefaultDataType = DataType::Float; enum class DataOption: UnsignedByte { Normalized = 1 << 0 diff --git a/src/Math/Algorithms/Svd.h b/src/Math/Algorithms/Svd.h index 9c4200515..5cde1de64 100644 --- a/src/Math/Algorithms/Svd.h +++ b/src/Math/Algorithms/Svd.h @@ -96,9 +96,14 @@ decomposition and least squares solutions"*. /* The matrix is passed by value because it is changed inside */ template std::tuple, Vector, Matrix> svd(RectangularMatrix m) { static_assert(rows >= cols, "Unsupported matrix aspect ratio"); - static_assert(T(1)+TypeTraits::epsilon() > T(1), "Epsilon too small"); constexpr T tol = Implementation::smallestDelta()/TypeTraits::epsilon(); + #ifndef CORRADE_GCC45_COMPATIBILITY + static_assert(T(1)+TypeTraits::epsilon() > T(1), "Epsilon too small"); static_assert(tol > T(0), "Tol too small"); + #else + CORRADE_ASSERT(T(1)+TypeTraits::epsilon() > T(1), "Epsilon too small", {}); + CORRADE_ASSERT(tol > T(0), "Tol too small", {}); + #endif constexpr std::size_t maxIterations = 50; Matrix v(Matrix::Zero); diff --git a/src/MeshTools/Test/TransformTest.cpp b/src/MeshTools/Test/TransformTest.cpp index 7d632c879..8c2569a7c 100644 --- a/src/MeshTools/Test/TransformTest.cpp +++ b/src/MeshTools/Test/TransformTest.cpp @@ -50,8 +50,8 @@ TransformTest::TransformTest() { &TransformTest::transformPoints3D}); } -/* GCC < 4.7 doesn't like constexpr here, don't know why */ -#ifdef CORRADE_GCC46_COMPATIBILITY +/** @bug GCC < 4.7 doesn't like constexpr here, don't know why */ +#if defined(CORRADE_GCC46_COMPATIBILITY) && !defined(CORRADE_GCC45_COMPATIBILITY) #define constexpr const #endif @@ -85,7 +85,7 @@ constexpr static std::array points3DRotatedTranslated{{ {15.0f, 1.5f, 1.5f} }}; -#ifdef CORRADE_GCC46_COMPATIBILITY +#if defined(CORRADE_GCC46_COMPATIBILITY) && !defined(CORRADE_GCC45_COMPATIBILITY) #undef constexpr #endif diff --git a/src/Test/SwizzleTest.cpp b/src/Test/SwizzleTest.cpp index e340c3fa8..936740147 100644 --- a/src/Test/SwizzleTest.cpp +++ b/src/Test/SwizzleTest.cpp @@ -53,6 +53,11 @@ void SwizzleTest::type() { constexpr Color3 origColor3; constexpr Color4 origColor4; + /* decltype(a) is not const because a is not constexpr under GCC <= 4.5 */ + #ifdef CORRADE_GCC45_COMPATIBILITY + #define const + #endif + constexpr auto a = swizzle<'y', 'a'>(orig); CORRADE_VERIFY((std::is_same::value)); @@ -73,6 +78,10 @@ void SwizzleTest::type() { constexpr auto g = swizzle<'y', 'a', 'y', 'x'>(origColor4); CORRADE_VERIFY((std::is_same>::value)); + + #ifdef CORRADE_GCC45_COMPATIBILITY + #undef const + #endif } void SwizzleTest::defaultType() {