Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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://lucid-motif.blogspot.com/2013/11/coding-puzzle-knight-sequences.html?

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.

like image 856
Peti Avatar asked Mar 18 '26 16:03

Peti


1 Answers

VC2012 does not support, and does not claim to support, the entire C++11 standard.

Initialiser lists are one of the things omitted.

VC2015 implements practically the entire C++11 standard, so you ought to upgrade to that. (I believe some SFINAE support is still missing).

like image 170
Bathsheba Avatar answered Mar 21 '26 05:03

Bathsheba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!