Przeglądaj źródła

build: some compilation fixes and tweaks for older (<= 4.6) versions of GCC.

undefined
Sam Hocevar 10 lat temu
rodzic
commit
1b5d3557ec
5 zmienionych plików z 55 dodań i 15 usunięć
  1. +3
    -0
      configure.ac
  2. +2
    -0
      src/image/codec/oric-image.cpp
  3. +40
    -6
      src/lol/base/array.h
  4. +7
    -6
      src/lol/base/features.h
  5. +3
    -3
      src/lol/math/vector.h

+ 3
- 0
configure.ac Wyświetl plik

@@ -35,6 +35,9 @@ dnl C++11 mode. Checked early so that we don't run into surprises.
LOL_TRY_CXXFLAGS(-std=c++11,
[AM_CXXFLAGS="${AM_CXXFLAGS} -std=c++11"
CXXFLAGS="${CXXFLAGS} -std=c++11"])
LOL_TRY_CXXFLAGS(-std=c++0x,
[AM_CXXFLAGS="${AM_CXXFLAGS} -std=c++0x"
CXXFLAGS="${CXXFLAGS} -std=c++0x"])

AC_LANG_PUSH(C++)
AC_MSG_CHECKING(for C++11 enum class support)


+ 2
- 0
src/image/codec/oric-image.cpp Wyświetl plik

@@ -12,6 +12,8 @@
# include "config.h"
#endif

#include <cctype>

#include <lol/main.h>
#include "../../image/image-private.h"



+ 40
- 6
src/lol/base/array.h Wyświetl plik

@@ -462,11 +462,6 @@ public:
array_base *m_array;
};

ConstIterator begin() const { return ConstIterator(this, 0); }
ConstIterator end() const { return ConstIterator(this, m_count); }
Iterator begin() { return Iterator(this, 0); }
Iterator end() { return Iterator(this, m_count); }

public:
inline int Count() const { return m_count; }
inline int Bytes() const { return m_count * sizeof(element_t); }
@@ -897,11 +892,50 @@ public:
#endif
};

/* Transitional alias for the camelcase version of lol::array */
/*
* C++11 iterators
*/

template<typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
typename array<T1,T2,T3,T4,T5,T6,T7,T8>::Iterator begin(array<T1,T2,T3,T4,T5,T6,T7,T8> &a)
{
return typename array<T1,T2,T3,T4,T5,T6,T7,T8>::Iterator(&a, 0);
}

template<typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
typename array<T1,T2,T3,T4,T5,T6,T7,T8>::Iterator end(array<T1,T2,T3,T4,T5,T6,T7,T8> &a)
{
return typename array<T1,T2,T3,T4,T5,T6,T7,T8>::Iterator(&a, a.Count());
}

template<typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
typename array<T1,T2,T3,T4,T5,T6,T7,T8>::ConstIterator begin(array<T1,T2,T3,T4,T5,T6,T7,T8> const &a)
{
return typename array<T1,T2,T3,T4,T5,T6,T7,T8>::ConstIterator(&a, 0);
}

template<typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
typename array<T1,T2,T3,T4,T5,T6,T7,T8>::ConstIterator end(array<T1,T2,T3,T4,T5,T6,T7,T8> const &a)
{
return typename array<T1,T2,T3,T4,T5,T6,T7,T8>::ConstIterator(&a, a.Count());
}

/*
* Transitional alias for the deprecated camelcase version of lol::array
*/

#if LOL_FEATURE_CXX11_TEMPLATE_ALIASES
template<typename T1, typename T2 = void, typename T3 = void,
typename T4 = void, typename T5 = void, typename T6 = void,
typename T7 = void, typename T8 = void>
using Array = array<T1, T2, T3, T4, T5, T6, T7, T8>;
#else
# define Array array
#endif

} /* namespace lol */



+ 7
- 6
src/lol/base/features.h Wyświetl plik

@@ -45,6 +45,9 @@
#define LOL_FEATURE_CXX11_CONSTEXPR 0
#define LOL_FEATURE_CXX11_ISNAN 0

/* This one is OK, except on GCC <= 4.6 */
#define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 1

#if defined __GNUC__ /* GCC */
# if defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L
# undef LOL_FEATURE_CXX11_CONSTEXPR
@@ -52,6 +55,10 @@
# undef LOL_FEATURE_CXX11_ISNAN
# define LOL_FEATURE_CXX11_ISNAN 1
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) < 470
# undef LOL_FEATURE_CXX11_TEMPLATE_ALIASES
# define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 0
# endif
#elif defined __has_feature /* Clang */
# if __has_feature(cxx_constexpr)
# undef LOL_FEATURE_CXX11_CONSTEXPR
@@ -59,12 +66,6 @@
# endif
#endif

#if LOL_FEATURE_CXX11_CONSTEXPR
# define LOL_CONSTEXPR constexpr
#else
# define LOL_CONSTEXPR /* Nothing */
#endif


/*
* Ensure we have nullptr.


+ 3
- 3
src/lol/math/vector.h Wyświetl plik

@@ -375,12 +375,12 @@ template <typename T> struct Cmplx
typedef Cmplx<T> type;

inline constexpr Cmplx() {}
inline constexpr Cmplx(T X) : x(X), y(0) {}
inline constexpr Cmplx(T X) : x(X), y(T(0)) {}
inline constexpr Cmplx(T X, T Y) : x(X), y(Y) {}

template<typename U>
explicit inline constexpr Cmplx(Cmplx<U> const &z)
: Cmplx<T>(z[0], z[1]) {}
: x(z.x), y(z.y) {}

LOL_COMMON_MEMBER_OPS(x)
LOL_NONVECTOR_MEMBER_OPS()
@@ -1136,7 +1136,7 @@ template <typename T> struct Quat

template<typename U>
explicit inline constexpr Quat(Quat<U> const &q)
: Quat<T>(q[0], q[1], q[2], q[3]) {}
: w(q.w), x(q.x), y(q.y), z(q.z) {}

Quat(matrix<3,3,T> const &m);
Quat(matrix<4,4,T> const &m);


Ładowanie…
Anuluj
Zapisz