stuck with STRUCT usage

Hi! I’m new to this forum, but I use arduino since about 1 year. I’m trying to use a struct in a project, and I’m stuck with this error:

test_enum_struct_matrix.cpp:34:11: error: expected initializer before ‘nodeMatrix’

Can anyone help me finding the error please?

Here it is the code:

  #define IO_COUNT_DIGITAL 54 // 0-53
  #define IO_COUNT_ANALOG 16 // 0-15

// definisco una struttura dati che identifica un pin
struct pinSingleAnalog {
  boolean flagReserved;
  byte unsigned pinValue;
};

struct pinSingleDigital {
  boolean flagInput;
  boolean flagReserved;
  boolean flagPwm;
  byte unsigned pinValue;
};

// pins array
struct pinMatrix {
  pinSingleAnalog analog[IO_COUNT_ANALOG];
  pinSingleDigital digital[IO_COUNT_DIGITAL];
}


pinMatrix nodeMatrix; // matrice di tutti i pin


void setup() 
{ 
  Serial.begin(9600);  
  
  //nodeMatrix.analog[0].flagReserved = true;
  //nodeMatrix.analog[2].flagReserved = true;
}

void loop() 
{
  
  for(int k=0; k<IO_COUNT_ANALOG; k++)
  {
   // Serial.println(pinDump(nodeMatrix[k]));
  }
  
  //  Serial.println(sizeof(nodeMatrix));
}

Thanks in advance :slight_smile:

Giuseppe

; after final } in declaration of struct pinMatrix?

Oh... thanks a lot! Ok, may be it's better for me if I go to sleep... :P

Thanks a lot again!

G.

Even after you add the ;, you will still have problems. You have not defined a type “pinMatrix”. What you have defined is a type “struct pinMatrix”.

So

pinMatrix nodeMatrix; // matrice di tutti i pin

will still be invalid.

it's C++ so pinMatrix is a type