Go Down

Topic: [SOLVED] warnings of Serial.println(F("Hi there")); (Read 2984 times) previous topic - next topic


Apr 20, 2012, 09:31 am Last Edit: Apr 21, 2012, 10:28 pm by optimistx Reason: 1
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?

Coding Badly


Locate and open WString.h

Above these two lines...
Code: [Select]
class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<__FlashStringHelper *>(PSTR(string_literal)))

Insert this...
Code: [Select]
#undef PROGMEM
#define PROGMEM __attribute__(( section(".progmem.data") ))

No guarantees from the management.   ;)


Apr 20, 2012, 12:05 pm Last Edit: Apr 21, 2012, 10:26 pm by optimistx Reason: 1


Insert this...
Code: [Select]
#undef PROGMEM
#define PROGMEM __attribute__(( section(".progmem.data") ))

No guarantees from the management.   ;)

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 :)

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)))

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131