John Pote schrieb:
> Hi everyone,
> 
> Have been using SDCC (Version 2.6.0 #4309 (Jul 28 2006)) for an Atmel 
> AT89C2051 (MCS51) chip which has the rather limited RAM space of 64 
> bytes. I wish to have a number of strings (char arrays) in code space as 
> well as arrays of pointers to such strings. (The array of pointers is so 
> the strings can be accessed via an index rather than by name.)
> 
> The code,
> 
>        const char Thw_cmd[] = "thw";
>        const char Cnts_cmd[] = "cnts";
>        const char *cmds[] = { Thw_cmd, Cnts_cmd, NULL };
> 
> duely places the strings in code space BUT the *cmds[] array in RAM 
> space. As a result it also adds quite a bit of code to initialise cmds[].
> 
> Is it possible to have the compiler place the cmds[] array in code space 
> as well? That being so how could I declare a function so it would take a 
> pointer so such a const array of pointers to const strings?

Only constants can be placed in code space. cmds is not constant (it is
a non-constant array of pointers to constants), thus has to be placed in
writeable memory. You probably want to write

const char * const cmds[] = { Thw_cmd, Cnts_cmd, NULL };

instead (this is a constant array of pointers to constants).

Philipp

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to