Initialising array data within struct... ?

Code lifted from larger project --

// ==================================================

IN THE SOURCE HEADER / DECLARATIONS BLOCK

struct MY_STRUCT {
byte SERIAL_DETAIL;
unsigned int INTERVAL;
byte HOST_LIST[8][4];
};
// --------------------------------------------------
MY_STRUCT pData;

--- then
// ==================================================

In SETUP(), MAIN() / LOOP() as you prefer...

// --- this line-by-line compiles as expected...

pData.HOST_LIST[0][0] = 192;
pData.HOST_LIST[0][1] = 168;
pData.HOST_LIST[0][2] = 0;
pData.HOST_LIST[0][3] = 1;

// ==================================================

// --- BUT THESE VARIATIONS THROW AN ERROR...

pData.HOST_LIST[0] = {192, 168, 0, 1};
:: etc ::
pData.HOST_LIST[3] = {11, 22, 33, 44};

** -- or --**

pData.HOST_LIST[] = {
{192, 168, 0, 1},
{1, 2, 3, 4},
{10, 20, 30, 40},
{11, 22, 33, 44}
} ;

// ==================================================
! ERROR:expected primary-expression before '{' token
// ==================================================

// --- Why not?

Thanks in advance for something to look for!
M

Why not?

Because the syntax for assigning data to elements of an existing array is different from the syntax for declaring an array with initial values. Get over it.

As your struct is a POD, you can initialize it like an array, then you can initialize the array inside it. An initialization only happens once, everything else is an assignment. Using your current method, you will have to write each line like you already have to assign the data.

MY_STRUCT pData = {  
  0,
  100,
  {
    { 192, 168, 0, 1 },
    { 10, 0, 0, 1 },
  }
};

If you make one small change, you can do what you want easily. Include IPAddress.h and change your array. Also your existing code will still work.

#include<IPAddress.h>

struct MY_STRUCT {
  byte SERIAL_DETAIL;  
  unsigned int INTERVAL;
  IPAddress HOST_LIST[8];
};

MY_STRUCT pData;

Then you can assign the data in one hit:

   pData.HOST_LIST[ 0 ] = IPAddress( 192, 168, 0, 1 );
  pData.HOST_LIST[ 1 ] = IPAddress( 10, 0, 0, 1 );

You can also initialize this struct pretty much the same:

MY_STRUCT pData = {  
  0,
  100,
  {
    IPAddress( 192, 168, 0, 1 ),
    IPAddress( 10, 0, 0, 1 ),
  }
};

IPaddress type - thanks
That'll do it.