'const' not working right?

Arduino 1.6.11

have a non-changing array of strings, example:

char *table = {
"S1",
"S2",
.
.
"S3"};

Total size is over 300 bytes.

Ok, first like this I get deprecation warnings and high RAM usage. Of course, it's variables.
So, I change it:

const char *table

This should move its storage from RAM to ROM, i.e. flash. Right?
Wrong.
Adding const makes my deprecation warnings go away. But RAM usage does not go down.

Why?

tj

The 'const' keyword only indicates to the compiler that the contents should not be changed; the compiler will issue a warning / error if you attempt to do so by accident.

What you are looking for is PROGMEM

Does not work with multidimensional arrays:

#include <avr/pgmspace.h>

const char tunes PROGMEM = {
‘b’,‘b’,‘a’,‘c’};

compiles fine.

******************************88

#include <avr/pgmspace.h>

const char *testArray PROGMEM = {
“ab”,“ab”,“ba”,“cd”};

Arduino: 1.6.11 (Linux), Board: “Arduino/Genuino Uno”

In file included from /home/tj/arduino-1.6.11/hardware/arduino/avr/cores/arduino/Arduino.h:28:0,
from sketch/test.ino.cpp:1:
test:4: error: variable ‘tunes’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
const char *tunes PROGMEM = {
^
exit status 1
variable ‘testArray’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

tj

Did you follow the link in reply #1?