views:

632

answers:

3

On an embedded target I use far pointers to access some parts of the memory map.

near pointer (without explicitely specifying __near):

unsigned int *VariableOnePtr;

Pointer to near pointer:

unsigned int **VariableOnePtrPtr;

far pointer:

unsigned int *__far VariableTwoPtr;

What is the correct way to declare a pointer to a far pointer? Does this pointer have to be a far pointer itself?

+6  A: 

I believe you would do this:

unsigned int * __far *VariableThreePtrPtr;

A far pointer to a far pointer would be:

unsigned int * __far * __far VariableFourPtrPtr;
Greg Hewgill
+2  A: 

You can also use typedefs for that, for example

typedef unsigned int *__far VariableTwoPtr_t;
VariableTwoPtr_t* VariableTwoPtrPtr;
dmityugov
+3  A: 

"__far" is a proprietary, non-standard extension of your platform, so there can't exist any generic way to use it. See the compiler and standard library manufaturer's manuals for how to use it correctly.

mh