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
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
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.
The compiler says
tst.cpp:31:7: error: statement-expressions are not allowed outside functions nor in template-argument lists
Maybe I should try using the flash library and use a variable to hold that string in PROGMEM
Do you really need to store data in FLASH? Doing so isn't "free." You will pay a performance penalty in terms of the time it takes to read from FLASH as well as the complexity in terms of the code necessary to access FLASH.
mkwired:
Do you really need to store data in FLASH? Doing so isn't "free." You will pay a performance penalty in terms of the time it takes to read from FLASH as well as the complexity in terms of the code necessary to access FLASH.
It's not that bad. In terms of time, the processor can read flash memory quickly. After all, it is getting instructions from it at the rate of a byte every clock cycle. Compare:
The only difference is changing "ld" to "lpm". The LPM instruction takes 3 clock cycles compared to 2 for LD. So, you lose one clock cycle (62.5 nS) per byte copied.