cancel
Showing results for 
Search instead for 
Did you mean: 

Contant pointers in C

parveen
Associate II
Posted on December 22, 2003 at 05:36

Contant pointers in C

6 REPLIES 6
parveen
Associate II
Posted on December 11, 2003 at 00:44

Has anyone tried to use pointer declaration with const prefix in C. Normally any declaration with const prefix goes to ROM or const segment but when I declare a pointer array with const prefix it goes to data segment.

const unsigned char * MyPtr[]={};

I want MyPtr to be stored in ROM

I have tried this with both Metrowerks and Cosmic compliers

Thanks in advance,

Regards,

praveenG

seeguard
Associate II
Posted on December 11, 2003 at 06:17

Try this:

#pragma INTO_ROM

const unsigned char * MyPtr[]={};

then look in the MAP file and check:

- VARIABLES:

MyPtr address len ( 2) ROM_VAR

atz
parveen
Associate II
Posted on December 11, 2003 at 10:53

Thanks a lot

It really works for Metrowerks. Could you suggest some method for Cosmic compiler also.

Does anyone knows how to do the same for cosmic compiler????

Thanks again

Regards,

PraveenG
sjo
Associate II
Posted on December 11, 2003 at 20:33

To make the pointer constant in cosmic do the following:

const unsigned char * const pString = ''string'';

Regards

sjo
parveen
Associate II
Posted on December 12, 2003 at 06:01

Thanks a lot

it works for cosmic also

Regards,

PraveenG
parveen
Associate II
Posted on December 22, 2003 at 05:36

I recently found out that Metrowerks has one technical note on this topic

Refer TN102:Contant pointer and pointer to constant (Search TN102 on www.metrowerks.com)

Regards,

Parveen

[ This message was edited by: praveenG on 22-12-2003 10:07 ]