I have a program that typedef's two structs. Each one has a corresponding function that returns a pointer to it....
typedef struct {
int x1;
} x;
x *a;
x *f(void) {
return a;
}
typedef struct {
int y1;
} y;
y *b;
y *g(void) {
return b;
}
void loop(void) {
}
void setup(void) {
}
This program produces the following error when compiled under the Arduino IDE...
sketch_nov10a:18: error: 'y' does not name a type
y *g(void)
If we copy/paste to switch the order of the two blocks like so...
typedef struct {
int y1;
} y;
y *b;
y *g(void) {
return b;
}
typedef struct {
int x1;
} x;
x *a;
x *f(void) {
return a;
}
void loop(void) {
}
void setup(void) {
}
...then we instead get the following error...
sketch_nov10a:18: error: 'x' does not name a type
x *f(void)
...so apparently the Arduino IDE only supports functions that return pointers to the first typedef'ed type defined in the file?
Is there a rational to this? How would you implement the above code to get it to compile under the Arduino IDE (it works fine in gcc
).