compile error using PROGMEM

/*
PROGMEM string demo
How to store a table of strings in program memory (flash),
and retrieve them.

Information copied from:
http://www.nongnu.org/avr-libc/user-manual/pgmspace.html
*/

const char string_0[] PROGMEM = "String 0";

// !!! *************** !!!
// I get a compile error: variable 'string_table' must be const in order to
// put in read-only section by means of 'attribute((progmem))'.
// But it is defined 'const'!!!

const char *string_table[] PROGMEM = {
string_0
};

char buffer[30];

void loop() {
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[0])));
Serial.println(buffer);
}

// The full code was copied verbatim and failed to compile.
// This version is stripped down for examination.

Use code tags when posting code. Edit your post and add

[code]before the code and [/code]

after the code.

Some additional information is, in general, highly appreciated :wink:
2)
Please post the errors that you get.
3)
Please let us know version of the IDE and the board that you use.

Thanks, Delta_G. The extra const worked. Someone needs to update the sample code in the Arduino Playground - PROGMEM. Also, the avr-libc/user-manual.

Done.

Beauty of a wiki, everybody can do that :wink:

BTW, there's no reason to copy it to a buffer:

const char string_0[] PROGMEM = "String 0";

const char * const string_table[] PROGMEM = {   
  string_0
};

void setup()
{
  Serial.begin( 9600 );
  Serial.println( (const __FlashStringHelper *) pgm_read_ptr(&string_table[0]) );
}

void loop() {}

Casting it to the FlashStringHelper type selects the method that prints the bytes directly from flash.

;D Thanks -dev, another jewel of information from the Forum. I will give it a try.