I'm trying to use structs with Arduino but cannot pass a struct pointer with a function call. Everything works fine when adding a main function and compiling for my computer with gcc but with the Arduino IDE I get errors.
The code I tried was:
typedef union
{
struct
{
unsigned unit :2;
unsigned channel:2;
unsigned status :1;
unsigned group :1;
unsigned remote :26;
};
unsigned long data;
} Signal;
Signal signal;
void testPassingStruct(Signal *variable)
{
variable->status = 1;
}
void setup()
{
signal.status = 1;
testPassingStruct(&signal);
}
void loop()
{
}
And the errors was:
structtest:2: error: variable or field ‘testPassingStruct’ declared void
structtest:2: error: ‘Signal’ was not declared in this scope
structtest:2: error: ‘variable’ was not declared in this scope