4

The code snippet:

static struct
{
     static const unsigned char myConstArray[] =
     {
           50, 51, 52, 52, 53, 54, 55, 55, 56, 57, 58, 58, 59, 60,
     };

     //more....
 }_SomeValues;

How could this work? (complains that after = a ; is missing)

Lundin
  • 195,001
  • 40
  • 254
  • 396
Thomas
  • 1,545
  • 3
  • 14
  • 25

3 Answers3

8

Change to:

static struct
{
     const unsigned char myConstArray[14];

} _SomeValues =
    {
        {
           50, 51, 52, 52, 53, 54, 55, 55, 56, 57, 58, 58, 59, 60,
        }
    };
hmjd
  • 120,187
  • 20
  • 207
  • 252
  • the real one is a bit bigger: {{{0,0,0,0,0},{0,0,0,0}},{0,0,0,0,0},{0,0,0,0}},0,{0,0},{50, 51, 52, 52, 53, 54, 55, 55, 56, 57, 58, 58, 59, 60, 61, 62, 63, 64, 65, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 98, 99, 100, 102, 103, 105, 106, 108, 109, 111, 112, 114, 115, 117, 118, 120, 122, 123, 125, 127, 129, 130, 132, 134, 136, 137, 139, 141, 143, 145,},}; – Thomas Oct 23 '12 at 15:11
1

you cant have static variables in struct

Ravindra Bagale
  • 17,226
  • 9
  • 43
  • 70
1

Probably the links below might help you as well

Static Const Initialised Structure Array in C++ Class

c++ Initializing a struct with an array as a member

Community
  • 1
  • 1
Omkant
  • 9,018
  • 8
  • 39
  • 59