瀏覽代碼

math: disable const union members on GCC prior to 4.6.

legacy
Sam Hocevar sam 12 年之前
父節點
當前提交
481212559e
共有 1 個文件被更改,包括 26 次插入0 次删除
  1. +26
    -0
      src/lol/math/vector.h

+ 26
- 0
src/lol/math/vector.h 查看文件

@@ -28,6 +28,14 @@
namespace lol
{

/* Some compilers do not support const members in anonymous unions. So
* far, GCC (>= 4.6), CLang (3.0) and Visual Studio (>= 2010) appear to
* work properly. */
#undef LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
#if defined __GNUC__ && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
# define LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS 1
#endif

#define DECLARE_VECTOR_TYPEDEFS(tname, suffix) \
template <typename T> struct tname; \
typedef tname<half> f16##suffix; \
@@ -128,6 +136,9 @@ template <typename T> struct BVec2
struct { T r, g; };
struct { T s, t; };

#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
# define const /* disabled */
#endif
XVec2<T,0x00> const xx, rr, ss;
XVec2<T,0x01> const xy, rg, st; /* lvalue */
XVec2<T,0x10> const yx, gr, ts; /* lvalue */
@@ -158,6 +169,9 @@ template <typename T> struct BVec2
XVec4<T,0x1101> const yyxy, ggrg, ttst;
XVec4<T,0x1110> const yyyx, gggr, ttts;
XVec4<T,0x1111> const yyyy, gggg, tttt;
#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
# undef const
#endif
};
};

@@ -287,6 +301,9 @@ template <typename T> struct BVec3
struct { T r, g, b; };
struct { T s, t, p; };

#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
# define const /* disabled */
#endif
XVec2<T,0x00> const xx, rr, ss;
XVec2<T,0x01> const xy, rg, st; /* lvalue */
XVec2<T,0x02> const xz, rb, sp; /* lvalue */
@@ -406,6 +423,9 @@ template <typename T> struct BVec3
XVec4<T,0x2220> const zzzx, bbbr, ppps;
XVec4<T,0x2221> const zzzy, bbbg, pppt;
XVec4<T,0x2222> const zzzz, bbbb, pppp;
#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
# undef const
#endif
};
};

@@ -468,6 +488,9 @@ template <typename T> struct BVec4
struct { T r, g, b, a; };
struct { T s, t, p, q; };

#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
# define const /* disabled */
#endif
XVec2<T,0x00> const xx, rr, ss;
XVec2<T,0x01> const xy, rg, st; /* lvalue */
XVec2<T,0x02> const xz, rb, sp; /* lvalue */
@@ -806,6 +829,9 @@ template <typename T> struct BVec4
XVec4<T,0x3331> const wwwy, aaag, qqqt;
XVec4<T,0x3332> const wwwz, aaab, qqqp;
XVec4<T,0x3333> const wwww, aaaa, qqqq;
#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
# undef const
#endif
};
};



Loading…
取消
儲存