When gcc-avr encounters an anonymous literal like printf("David"), the "David" is copied to SRAM so that printf() is always passed a SRAM address.
I would have assumed that:
printf("hello world"); // string in CODE
char string[] = "universe"; // string in DATA
char empty[10]; // string in BSS
The default behaviour means that using normal functions like strcmp() will always be looking at strings in SRAM.
The alternatives are having generic pointers or having different functions like strcmp() and strcmp_P().
However it does use up valuable SRAM.
Now I know that I can wrap literals with PSTR() etc.
And I can use modifiers to force stuff into CODE. And use pgm_read_byte() etc to access them.
My questions are:
1. is there a gcc-avr switch to leave literals in FLASH where they belong ?
2. is there a ld-avr switch to tell you when you have run out of SRAM ?
3. is there a tidy way of writing legible code that forces gcc-avr to put literals in CODE without switches ?
4. have I missed everything in the gcc-avr documentation ?
David.