Changeset 1154


Ignore:
Timestamp:
Mar 6, 2012, 8:11:19 PM (10 years ago)
Author:
sam
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/math/vector.h

    r1153 r1154  
    2828namespace lol
    2929{
     30
     31/* Some compilers do not support const members in anonymous unions. So
     32 * far, GCC (>= 4.6), CLang (3.0) and Visual Studio (>= 2010) appear to
     33 * work properly. */
     34#undef LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
     35#if defined __GNUC__ && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
     36#   define LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS 1
     37#endif
    3038
    3139#define DECLARE_VECTOR_TYPEDEFS(tname, suffix) \
     
    129137        struct { T s, t; };
    130138
     139#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
     140#   define const /* disabled */
     141#endif
    131142        XVec2<T,0x00> const xx, rr, ss;
    132143        XVec2<T,0x01> const xy, rg, st; /* lvalue */
     
    159170        XVec4<T,0x1110> const yyyx, gggr, ttts;
    160171        XVec4<T,0x1111> const yyyy, gggg, tttt;
     172#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
     173#   undef const
     174#endif
    161175    };
    162176};
     
    288302        struct { T s, t, p; };
    289303
     304#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
     305#   define const /* disabled */
     306#endif
    290307        XVec2<T,0x00> const xx, rr, ss;
    291308        XVec2<T,0x01> const xy, rg, st; /* lvalue */
     
    407424        XVec4<T,0x2221> const zzzy, bbbg, pppt;
    408425        XVec4<T,0x2222> const zzzz, bbbb, pppp;
     426#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
     427#   undef const
     428#endif
    409429    };
    410430};
     
    469489        struct { T s, t, p, q; };
    470490
     491#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
     492#   define const /* disabled */
     493#endif
    471494        XVec2<T,0x00> const xx, rr, ss;
    472495        XVec2<T,0x01> const xy, rg, st; /* lvalue */
     
    807830        XVec4<T,0x3332> const wwwz, aaab, qqqp;
    808831        XVec4<T,0x3333> const wwww, aaaa, qqqq;
     832#if LOL_NO_CONST_MEMBERS_IN_ANONYMOUS_UNIONS
     833#   undef const
     834#endif
    809835    };
    810836};
Note: See TracChangeset for help on using the changeset viewer.