[SOLVED] warnings of Serial.println(F("Hi there"));

To save RAM I put message texts to flash memory e.g. by using the F()-function. It works well. Thanks to developers!

Anyhow, the compiler gives a red warning to verbose output list at every invocation of F(): " warning: only initialized variables can be placed into program memory area".

It makes tedious to find other potentilly useful warnings among those over 100 F() -related messages in my program. (red and white distinction is otherwise a very good idea).

There has been discussions about this at least some months ago e.g. in avg-freaks forum, without having any easy solution to suppress this warning message but no others.

Have you now a solution for this?


Locate and open WString.h

Above these two lines…

class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<__FlashStringHelper *>(PSTR(string_literal)))

Insert this…

#undef PROGMEM
#define PROGMEM __attribute__(( section(".progmem.data") ))

No guarantees from the management. :wink:

Thank you very much!
The change helped, and it was easy to spot 3 other red warnings. Now everything is snowwhite. You made my day :slight_smile:

By the way, I had earlier added the word “const” to the definition of __FlashStringHelper. I do not remember the reason why :(. So now those statements are like this:

#undef PROGMEM
#define PROGMEM attribute(( section(".progmem.data") ))
class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))