In pgmspace.h
, PROGMEM
is defined as __ATTR_PROGMEM__
, which is defined as __attribute__((__progmem__))
. AFAIK, __attribute__
is GNU only. Since C++ 11, we have the attribute specifier sequence.
I can't use [[__progmem__]]
instead of PROGMEM
. The error is
warning: '__progmem__' attribute directive ignored [-Wattributes]
Shouldn't that work equally?
Why would I want to do that?
- Clarity: When I first read code that used PROGMEM, I thought that this is the variable name (being a constant, we have a conding guideline that it should be upper case, which matched). Reading on, I found the real variable name, which confused me. Putting it into square brackets would immediately have made clear that it's an attribute and not a name.
- Portability:
[[ ]]
is Standard C++, whereas__attribute__
is not.