Actually there is a sort of workaround (I think) for the compiler bug that gives spurious warnings of this type, but it's kind of hokey (some would say that it's downright butt-ugly). Maybe that's why the Arduino folks disabled the warnings. (Or at least one of the reasons.)
Try the following sketch with your avr-gcc script mod that enables warnings.
I haven't actually changed anything associated with avr-gcc or with Arduino itself, but I have compiled (standalone) stuff like this with avr-gcc version 4.3.4 (compiled from source on my Centos 5.5 Linux system) and the warnings disappear with this magical incantation. See Footnote.
// A possible workaround to eliminate spurious warnings
// about "only initialized variables can be placed in program memory"
// when you enable compiler warnings.
//
// Maybe that's why the Arduino folks disabled the warnings.
//
// Note that you do NOT need the TWO foo statements if you are
// not enabling compiler warnings.
//
// You can just use
//
// const prog_uchar foo[7] PROGMEM = {0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54,0x32};
//
// or even
//
// const byte foo[7] PROGMEM = {0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54,0x32};
//
// In other words, those typedefs in <avr/pgmspace.h> don't really buy us much.
//
//
// davekw7x
//
#include <avr/pgmspace.h>
extern const byte foo[] PROGMEM;
const byte foo[7] = {0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54,0x32};
void setup()
{
Serial.begin(9600);
}
void loop()
{
int i;
byte n;
char buffer[10];
Serial.println("Using pgm_read_byte_near:");
for (i = 0; i < 7; i++) {
n = pgm_read_byte_near(&foo[i]);
sprintf(buffer, "%02X ", n);
Serial.print(buffer);
}
Serial.println(); Serial.println();
Serial.println("Using normal read:");
for (i = 0; i < 7; i++) {
n = foo[i];
sprintf(buffer, "%02X ", n);
Serial.print(buffer);
}
Serial.println();
while(1)
;
}
By using a loop with pgm_read_byte and another with "normal" memory access you can see whether the array is actually in program memory. Then you can try other magical incantations and see if there is something that suits your style.
Regards,
Dave
Footnote:
"Any sufficiently advanced technology is indistinguishable from magic."
---Arthur C. Clarke (1917--2008)