I can't compile this, my C is rusty....

Clearly I am doing something wrong, but I can't see what, this simplified version of code won't compile:

enum Btn_Func_t { On, Off, EOBtn} ;
typedef struct
{
  Btn_Func_t     func;
} Btnstruct;
Btnstruct DeskBtn[]=
{//func
  {On},
  {Off},

  {EOBtn}, //marks end of list - MUST be present
};
void setup(){}

void loop()
{
  int idx = GetBtnIdx(On);
}

int GetBtnIdx(Btn_Func_t f)
{
  int i=0;
  return(i);
}

The errors I get are: sketch_oct19a.ino:4:15: error: 'Btn_Func_t' was not declared in this scope sketch_oct19a.ino: In function 'void loop()': sketch_oct19a.ino:17:25: error: 'GetBtnIdx' cannot be used as a function sketch_oct19a.ino: In function 'int GetBtnIdx(Btn_Func_t)': sketch_oct19a.ino:20:27: error: 'int GetBtnIdx(Btn_Func_t)' redeclared as different kind of symbol sketch_oct19a.ino:4:5: error: previous declaration of 'int GetBtnIdx'

Obviously the code has been slimmed down such that when it compiles, it won't do anything useful, I just want to get this method working... Can anyone help?

enum Btn_Func_t { On, Off, EOBtn} ;

The _t convention is for use in standard, all-compilers-support-the-type-the-same-way types. Btn_func_t isn't even a type. So, lose the _t.

The IDE does not always create function prototypes. Add your own.

You really should be defining enums and structs in a header file, not in an ino file.

The _t is leftover from when I did try making them a type, which also didn't work. As I said, I simplified the code down to the bare minimum to show the problem, this is a separate ino just for this purpose. header files I agree with, but one problem at a time :)

it compiles just fine with the latest IDE

which version do you use?

1.7.11 from arduino.org I'll have a play with 1.6 from here in the morning :)

Hi,

The dot-org version of the IDE is reputed to be pretty far behind the dot-cc version (currently 1.6.12 I believe).

best, Michael

Ah, that's good to know! Thank you all for your efforts :)