Pages: [1]   Go Down
Author Topic: [SOLVED] warnings of Serial.println(F("Hi there"));  (Read 1555 times)
0 Members and 1 Guest are viewing this topic.
Finland
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: April 21, 2012, 03:28:09 pm by optimistx » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12773
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


http://old.nabble.com/C%2B%2B-with-PSTR-td26664456.html

Locate and open WString.h

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

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

No guarantees from the management.   smiley-wink
Logged

Finland
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...

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

No guarantees from the management.   smiley-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 smiley

By the way, I had earlier added the word "const" to the definition of __FlashStringHelper. I do not remember the reason why smiley-sad. So now those statements are like this:
Quote
#undef PROGMEM
#define PROGMEM __attribute__(( section(".progmem.data") ))
class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
« Last Edit: April 21, 2012, 03:26:38 pm by optimistx » Logged

Pages: [1]   Go Up
Jump to: