EmbeddedRelated.com
Forums
Memfault Beyond the Launch

far pointer declaration

Started by seecwriter February 28, 2011
How would you declare a pointer to a far array that's in local memory?
No matter what I do the compiler pukes (DC v10.64).

const far char myarray[] = "my message";
...
far char *p;

p = myarray; <--- WARNING: Incompatible types!

On 2/28/2011 7:46 PM, seecwriter wrote:
> How would you declare a pointer to a far array that's in local memory?
> No matter what I do the compiler pukes (DC v10.64).
>
> const far char myarray[] = "my message";
> ...
> far char *p;
>
> p = myarray; <--- WARNING: Incompatible types!
>

Have not tried it in DC (just Softools) but would be

char far * p;

May need to be:

const char far * p: since it is pointing to a const array. Can always be
cast as needed.

'far' operates to the right so it says the '*' is far.

far char *p;

says that p will be stored far but still is a pointer to near.

--
------
Scott G. Henion, Consultant
Web site: http://SHDesigns.org
Rabbit libs: http://shdesigns.org/rabbit/
------

It was the "const" the compiler was complaining about.
Once I added a cast the warning goes away.

FYI, according to the DC manual, "far" can go on either side of the
base type. So "far char *" is just as good as "char far *".

Thanks.

--- In r..., Scott Henion wrote:
>
> On 2/28/2011 7:46 PM, seecwriter wrote:
> > How would you declare a pointer to a far array that's in local memory?
> > No matter what I do the compiler pukes (DC v10.64).
> >
> > const far char myarray[] = "my message";
> > ...
> > far char *p;
> >
> > p = myarray; <--- WARNING: Incompatible types!
> > Have not tried it in DC (just Softools) but would be
>
> char far * p;
>
> May need to be:
>
> const char far * p: since it is pointing to a const array. Can always be
> cast as needed.
>
> 'far' operates to the right so it says the '*' is far.
>
> far char *p;
>
> says that p will be stored far but still is a pointer to near.
>
> --
> ------
> Scott G. Henion, Consultant
> Web site: http://SHDesigns.org
> Rabbit libs: http://shdesigns.org/rabbit/
> ------
>


Memfault Beyond the Launch