I am using avr-gcc 4.5.1 on FreeBSD 7.0 and am unable to compile the example flash_streaming file for the flash library.
The other example file flash_example is compiling though.
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 have checked that this line of code after preprocessing is
Serial << (reinterpret_cast<__FlashStringHelper *>((extension({static const char __c[] attribute((progmem)) = ("This is a test string"); &__c[0];})))) ;
Could someone give me pointers as to whats going wrong?
FLASH_STRING(big_string, "The quick brown fox\n"); // Compiles
void setup()
{
Serial.begin(115200); //
Serial << big_string; // Compiles
Serial << F("jumped over \n"); // Does NOT Compile
Serial << "the lazy sleeping dogs"; // Compiles
}
////////The pre-processed output is shown below
static const char big_string_flash[] attribute((progmem)) = "The quick brown fox\n"; _FLASH_STRING big_string(big_string_flash);;
void setup()
{
Serial.begin(115200);
Serial << big_string;
Serial << (reinterpret_cast<__FlashStringHelper *>((extension({static const char __c[] attribute((progmem)) = ("jumped over \n"); &__c[0];}))
Serial << "the lazy sleeping dogs";
}
////// Compiler error
tst.cpp:9:15: error: reinterpret_cast from type 'const char*' to type '__FlashStringHelper*' casts away qualifiers
Yes - the only difference from the stock arduino-1.0-linux.tgz is that I have added makefiles to ease compilation, and patched Print.h according to the instructions in Flash/patching_print.txt
It is not a problem with the flash library as the << works in general but F() does not - even when used without the flash library.
Serial.print(F("Hello World")); does not work and gives the same error. BTW I am using avr-gcc-4.5.1