Go Down

Topic: typedef in function definition has a problem (Read 4286 times) previous topic - next topic

mikeasl

The following program produces a compiler error (Arduino 0011 alpha):
struct foo{
 int    a;
 int    b;
};
typedef struct foo FOO;
FOO  myvar[21];
FOO *myFunct(){}
void setup(){}
void loop(){}

ERROR is: error: expected constructor, destructor, or type conversion before '*' token
If I change
<FOO *myFunct(){}>
to
<struct foo *myfunct(){}> it compiles just fine.

Mike...
mikeasl@mac.com

mellis

You need to put type definition inside a separate header file, as the function prototypes that are generated by the IDE are inserted above the typedef (but below pre-processor directives like #include).  This header can be another tab in your sketch; use the right facing arrow in the upper right of the IDE.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy