![Can I take advantage of [[__progmem__]] as an alternative of PROGMEM? Can I take advantage of [[__progmem__]] as an alternative of PROGMEM?](https://techtoguide.com/wp-content/uploads/2023/10/Why-wont-my-servo-and-ultrasonic-sensor-work-together.png)
[ad_1]
Arduino Stack Change is a query and reply website for builders of open-source {hardware} and software program that’s suitable with Arduino. It solely takes a minute to enroll.
Anyone can ask a query
Anyone can reply
The perfect solutions are voted up and rise to the highest
Requested
Seen
47 occasions
In pgmspace.h
, PROGMEM
is outlined as __ATTR_PROGMEM__
, which is outlined as __attribute__((__progmem__))
. AFAIK, __attribute__
is GNU solely. Since C++ 11, now we have the attribute specifier sequence.
I can not use [[__progmem__]]
as an alternative of PROGMEM
. The error is
warning: ‘__progmem__’ attribute directive ignored [-Wattributes]
Should not that work equally?
Why would I need to try this?
- Readability: After I first learn code that used PROGMEM, I believed that that is the variable identify (being a continuing, now we have a conding guideline that it ought to be higher case, which matched). Studying on, I discovered the actual variable identify, which confused me. Placing it into sq. brackets would instantly have made clear that it is an attribute and never a reputation.
- Portability:
[[ ]]
is Normal C++, whereas__attribute__
is just not.
Possibly I ought to simply learn the whole documentation…
Underneath Normal Attributes, we see the attributes that include the C++ Normal. __progmem__
is not one among them.
Following the instance for syntax 2, I attempted [[gnu::__progmem__]]
, which compiles. So this helps with Readability, however because it now has the gnu
namespace, it would not assist with Portability.
1
[ad_2]