lundi 25 juillet 2016

Visual Studio C++11g compilation error - too many initializers

I am trying to compile the following source code using Visual Studio 2012 Professional and I getting the compilation errors. But the same code is working in Visual Studio 2013. When I check Vs 2012, it supports most of the C++ 11 features. The program is built using C++ 11 compliant compiler. I found this program http://ift.tt/2aqkf5F?

typedef enum          { _A,_B,_C,_D,_E,_F,_G,_H,_I,_J,_K,_L,_M,_N,_O,_1,_2,_3 } TKeyIdentity;

typedef std::vector<TKeyIdentity const>     TKeyPath
typedef std::vector<TKeyPath const>         TKeyMap;

const TKeyMap keyPad =
{
{ _H, _L },         // A
{ _I, _K, _M },     // B
{ _F, _J, _L, _N }, // C
{ _G, _M, _O },     // D
{ _H, _N },         // E  
{ _C, _M, _1 },     // F  (_1) not valid for 2 moves followed by 1 move rule
{ _D, _N, _2 },     // G
{ _A, _E, _K, _O, _1, _3 }, // H
{ _B, _L, _2 },     // I
{ _C, _M, _3 },     // J  (_3) not valid for 2 moves followed by 1 move rule
{ _B, _H, _2 },     // K
{ _A, _C, _I, _3 }, // L
{ _B, _D, _F, _J }, // M
{ _C, _E, _G, _1 }, // N
{ _D, _H, _2 },     // O (oh)
{ _F, _H, _N },     // 1
{ _G, _I, _K, _O }, // 2 (_K) & (_O) not valid for 2 moves followed be 1 move rule
{ _H, _J, _L }      // 3
};   

const TKeyPath keyPadRoot =
{
_A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _1, _2, _3
}

The keyPad and keyPadRoot initializers are giving the below errors

Error 3 error C1903: unable to recover from previous error(s); stopping compilation Error 2 error C2078: too many initializers
Error 1 error C2552: 'keyPad' : non-aggregates cannot be initialized with initializer list

Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire