View Issue Details

IDProjectCategoryView StatusLast Update
0003396Spring engineGeneralpublic2013-01-18 18:44
ReporterMadrMan Assigned Toabma  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0003396: Compile error on VS2012
DescriptionI've been trying to compile latest develop with VS2012, and I've been getting an error:

rts/Game/TraceRay.h(20): error C2057: expected constant expression

Which is at the end of this enum:
    enum {
        NOENEMIES = 1,
        NOFRIENDLIES = 2,
        NOFEATURES = 4,
        NONEUTRALS = 8,
        NOGROUND = 16,
        BOOLEAN = 32, // skip further testings after the first collision
        NOUNITS = NOENEMIES | NOFRIENDLIES | NONEUTRALS
    };

I've tracked this down to System/Misc/BitwiseEnum.h being included which has this defined:

template <class Enum>
inline BitwiseEnum<Enum> operator | (Enum a, Enum b)
{
    return BitwiseEnum<Enum>(a) | BitwiseEnum<Enum>(b);
}

Apparently, VS2012 applies that global operator to the enum definition, causing it to give an error as the result of that isn't an integral value.

Same problem as here: http://stackoverflow.com/questions/13827599/oaidl-h319-error-c2057-expected-constant-expression

There are 2 ways to solve this from what I've found.
* Stick BitwiseEnums in a namespace so the global operator isn't applied by default (not sure if the global operator can even be used in that case without having to use the entire namespace)
* Change the enum to 'enum class' when C++0x is available, as it seems to be compile fine when i do so.

Suggestions are very welcome.
TagsNo tags attached.
Checked infolog.txt for Errors

Activities

MadrMan

2013-01-12 13:12

developer   ~0009593

Upon further testing, it seems that the BitwiseEnums inclusion also breaks an enum or two in boost, so changing to enum class won't help much.

abma

2013-01-15 08:12

administrator   ~0009598

Last edited: 2013-01-15 08:13

so, just put it in a namespace as it seems to be the only solution?! i don't see any drawbacks...

zerver

2013-01-16 18:14

reporter   ~0009601

I don't have 2012, but let me guess this works?

NOUNITS = (int)NOENEMIES | NOFRIENDLIES | NONEUTRALS

MadrMan

2013-01-18 14:45

developer   ~0009613

zerver, no it doesn't. the error is on the actual enum not in the code where it is used.

Opened a pull request with all the fixes i needed to make to get it to compile & run for me in vs2012 (which weren't a lot)

Issue History

Date Modified Username Field Change
2013-01-12 12:58 MadrMan New Issue
2013-01-12 13:12 MadrMan Note Added: 0009593
2013-01-15 08:12 abma Note Added: 0009598
2013-01-15 08:13 abma Note Edited: 0009598
2013-01-16 18:14 zerver Note Added: 0009601
2013-01-18 14:45 MadrMan Note Added: 0009613
2013-01-18 18:44 MadrMan Changeset attached => spring develop e08ad975
2013-01-18 18:44 abma Changeset attached => spring develop c610ea77
2013-01-18 18:44 abma Assigned To => abma
2013-01-18 18:44 abma Status new => resolved
2013-01-18 18:44 abma Resolution open => fixed