I want to write

  static struct MenuLevel {
    uint8_t (*get)(void);
    void (*set)(uint8_t);
    uint8_t max;
    const char *name;
  } menu[] = {
    { .get = &get_mode,  .set = &set_mode,  .max = MODE_MAX,
      .name = PSTR("MODE"), },
    { .get = &get_sense, .set = &set_sense, .max = 1,
      .name = PSTR("SENSE"), },
    { .get = &get_range, .set = &set_range, .max = 1,
      .name = PSTR("RANGE"), },
  };

but I can't, because it fails to compile:

  In file included from src/ui.c:5:0:
  src/ui.c:263:13: error: braced-group within expression allowed only inside a 
function
       .name = PSTR("MODE"), },

This is due to the definition of PSTR which looks like

  # define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); 
&__c[0];}))

Does anyone have a suggestion on how I can have a string pointer to a
flash-stored string in a static initialiser?

-- 
Paul "LeoNerd" Evans

leon...@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

Attachment: pgpwHrM8t3pol.pgp
Description: OpenPGP digital signature

_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to