cancel
Showing results for 
Search instead for 
Did you mean: 

constant pointer to constant character string?

philip1
Associate II
Posted on May 31, 2006 at 12:23

constant pointer to constant character string?

4 REPLIES 4
philip1
Associate II
Posted on May 30, 2006 at 13:27

Hi All,

I'm using the GCC compiler tools for an STR730 CPU and I want to define an array of strings that will be stored in the Flash memory. I am using

const char *HelpStrings[] = {

''a string of text\r\n''

...

};

which puts the strings of text in ROM but builds the table of pointers in RAM. Does anyone know how I can tell the compiler to build the pointer table in ROM space as well? I just don't want to waste RAM space on something that will never be changed!!

Thanks for any suggestions

PhilipJ

ben2
Associate II
Posted on May 31, 2006 at 05:08

try doing

const char *const HelpStrings[] = {

philip1
Associate II
Posted on May 31, 2006 at 11:54

thanks for the suggestion, sadly it generates errors:

error: conflicting types for 'HelpStrings'

error: previous declartion of 'HelpStrings' was here

warning: array 'HelpStrings' assumed to have one element

!!!

Don't quite know what they mean (particularly the middle one)

but they only come in when the 2nd const is added.

Maybe I'll just resign myself to having the pointer table in RAM

PhilipJ

ben2
Associate II
Posted on May 31, 2006 at 12:23

that is strange I am using gcc v3.4 and have no such problems.

e.g.

const char *const data[] = {

''data'',

''''

};

Is the variable decleration inside a header file ?

edit:

I have also seen examples where

char const * const

is used, perhaps you could try that.

[ This message was edited by: ben_fnr on 31-05-2006 16:37 ]