From: Vincent Trouilliez <[EMAIL PROTECTED]>
[...]
However, something still causes me trouble apparently....

The actual/complete declaration of my "menu" data type / structure is :

struct menu {
        uint8_t options; //options to control the operation of the menu
        uint8_t nb;     //number of options present in this menu
        char    desc[][21];     //table to store the strings for each menu entry
        void (*fp[])(void);     //table to store the pointers to the functions
};

The compiler complains that :

ui.h:29: error: flexible array member not at end of struct
make: *** [main.o] Error 1

I got around this by giving a fixed size to 'desc', which worked fine
for debugging the pointer part of things, but it's otherwise no good of
course.
What's the trick ?

Sounds like you're in deep yogurt.

Do you know what a flexible array member is? Did you know you defined two of them? Did you reserve space for the function pointers?

You probably need to seperate the tables from the structure. Something like this:

  struct menu_entry
  {
     char desc[21];  // or perhaps simply "char * desc"
     void (*fp)(void);
  };
  struct menu
  {
        uint8_t options; //options to control the operation of the menu
        uint8_t nb;     //number of options present in this menu
        struct menu_entry * entries;
  };

Then use them something like

  struct menu_entry menu_x_entries[] = {
     { "opt 1", fn_x1},
     { "opt 2", fn_x2},
     { "opt 3", fn_x3}
  };
  struct menu menu_x = {0, 3, menu_x_entries};

Hopefully this is enough to get you started. You'll have to work out the pgmspace details out yourself.

Regards,
  -=Dave




_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to