Pages: [1]   Go Down
Author Topic: typedef in function definition has a problem  (Read 3649 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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(){}>
<struct foo *myfunct(){}> it compiles just fine.


Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
Karma: 12
Posts: 3538
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Pages: [1]   Go Up
Jump to: