Go Down

Topic: What does the F() do exactly? (Read 7 times) previous topic - next topic

mromani


kb3dow

Could someone please help me out with this, I am unable to get the F() macro compiled on FreeBSD.
I am using avr-gcc and the arduino 1.0 codebase.
The following line
Serial << F("This is a test string");
throws up an error by the compiler which says

flash_streaming.cpp:210:13: error: reinterpret_cast from type 'const char*' to type '__FlashStringHelper*' casts away qualifiers

I apologize for cross posting, but I already asked the same question in an earlier post - but didn't make any headway
http://arduino.cc/forum/index.php?topic=95572.new

The command I am issuing is -
avr-gcc tst.cpp  -mmcu=atmega328p -DF_CPU=16000000UL -Os -w -Wl,--gc-sections -ffunction-sections -fdata-sections -DARDUINO=100  -I /home/rr/code/arduino//include/arduino/ -I . -c -o tst.o

mkwired


Serial << F("This is a test string");


Try
Serial.print( F("This is a test string") );
or
Serial.println( F("This is a test string") );

kb3dow

It has nothing to do with the << operator, even Serial.print(F("Hello World")) has the same problem.
Serial.print(F("Hello World"));
gives
tst.cpp:19:18: error: reinterpret_cast from type 'const char*' to type '__FlashStringHelper*' casts away qualifiers

I have a medium sized multi-file sketch compiling and functioning using avr-gcc, so there is no problem in general with compiling/linking etc. But this particular issue has me puzzled.

mkwired

What version of avr-gcc are you using?

Go Up