I'm working on my Arduino project, which is the only C/C++ compiler I'm using. I'm stumbling on why I cannot use the struct as a type on my function parameter.
Not sure if this specific to Arduino compiler design, or general C/C++ programming.
struct myStruct_t {
byte var1;
byte var2;
};
myStruct_t myStruct;
void setup() {
}
void loop() {
}
void myFunc(myStruct_t *myVar) {
int i = 0;
}
This results in a compiler errors:
error: variable or field 'myFunc' declared void
error: 'myStruct_t' was not declared in this scope
error: 'myVar' was not declared in this scope
If I comment out the declaration of the "myFunc" then it compiles as is. I'm not clear on why I can declare and use a variable of that structure, however I can use the structure as a parameter type. Does the "struct" type not act as a type for parameter use?
Thanks.