Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • I don't know how to "tag a pointer", but when working with a magic number I would make that a void pointer? Commented Dec 14, 2017 at 10:14
  • Here is an example of mapping EEPROM, SRAM and PROGMEM to a single address space: github.com/mikaelpatel/Arduino-Shell/blob/master/Shell.h#L1058 Commented Dec 14, 2017 at 10:35
  • 1
    The simplest scheme is to use the sign bit for PROGMEM, i.e. add 0x8000 to PROGMEM pointers. Commented Dec 14, 2017 at 10:39
  • I don't get it. So when I get a __FlashStringHelper* I add 0x8000 to mark that it points to PROGMEM. But then I still can't store that in a const char* variable, can I? Commented Dec 14, 2017 at 10:42
  • Tell the compiler what you want: uint16_t str = 0x8000U + (uint16_t) str_P; strings[numStrings++] = (const char*) str; Commented Dec 14, 2017 at 11:51