macros instead of typedefs in <avr/pgmspace.h>

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It has been discovered recently by the gcc developers, that application of the __progmem__ attribute to typedefs is broken, and the gcc developers refused to fix it, for whatever reason ( , closed as WON'T FIX).

As a consequence, the header in avr-libc is seen as broken, too, as it contains quite a couple of such typedefs. The proposed fix is to tag the typedefs in it as "deprecated", which has been already implemented in current development version of this file (note that the actual typedefs are in the "not-DOXYGEN" branch and don't match those embedded in the "documentation").

I expressed my concerns in and in the avrfreaks post it links to, and suggested using macros instead. This proposal was rejected until "proven as safe" (whatever that means) .

I would like to ask those, who do use these macros, to try both variants in real-world applications, and comment on them.

My proposed pgmspace.h with the macros is in the appendix (I did not care to doxygenize it).

Note, that if you used to declare pointers to the typedef'd types in your sources then those will warn about "attribute progmem being ignored", but should be harmless otherwise. If you use the PGM_VOID and PGM_P macros, those have been "sanitized" alredy so they won't throw a warning (and should still be OK IMHO). Maybe a set of macros for such pointers as a plan for future should be considered to be added to pgmspace.h, too.


Jan Waclawek