diff --git a/src/lol/math/vector.h b/src/lol/math/vector.h index fd4d6b4d..8893cda0 100644 --- a/src/lol/math/vector.h +++ b/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 struct tname; \ typedef tname f16##suffix; \ @@ -128,6 +136,9 @@ template struct BVec2 struct { T r, g; }; struct { T s, t; }; +#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS +# define const /* disabled */ +#endif XVec2 const xx, rr, ss; XVec2 const xy, rg, st; /* lvalue */ XVec2 const yx, gr, ts; /* lvalue */ @@ -158,6 +169,9 @@ template struct BVec2 XVec4 const yyxy, ggrg, ttst; XVec4 const yyyx, gggr, ttts; XVec4 const yyyy, gggg, tttt; +#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS +# undef const +#endif }; }; @@ -287,6 +301,9 @@ template 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 const xx, rr, ss; XVec2 const xy, rg, st; /* lvalue */ XVec2 const xz, rb, sp; /* lvalue */ @@ -406,6 +423,9 @@ template struct BVec3 XVec4 const zzzx, bbbr, ppps; XVec4 const zzzy, bbbg, pppt; XVec4 const zzzz, bbbb, pppp; +#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS +# undef const +#endif }; }; @@ -468,6 +488,9 @@ template 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 const xx, rr, ss; XVec2 const xy, rg, st; /* lvalue */ XVec2 const xz, rb, sp; /* lvalue */ @@ -806,6 +829,9 @@ template struct BVec4 XVec4 const wwwy, aaag, qqqt; XVec4 const wwwz, aaab, qqqp; XVec4 const wwww, aaaa, qqqq; +#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS +# undef const +#endif }; };