If a member function gets the modifier __far, the this pointer is a __far pointer in the context of a call to that function. This is useful, for instance, if the owner class of the function is not allocated on the default data page. See the following listing.
class A { public: void f_far(void) __far { /* __far version of member function A::f() */ } void f(void) { /* normal version of member function A::f() */ } }; #pragma DATA_SEG MyDirectSeg // use direct addressing mode A a_normal; // normal instance #pragma DATA_SEG __FAR_SEG MyFarSeg // use extended addressing mode A __far a_far; // __far instance void main(void) a_normal.f(); // call normal version of A::f() for normal instance a_far.f_far(); // call __far version of A::f() for __far instance }
With inheritance, it no longer suffices to use __far with member functions only. Instead, the whole class should be qualified with the __far modifier. Thus, the compiler is instructed to handle ' this' as a far pointer in all the contexts related to the declaration and definition of that class, for example vptr initialization, assignment operator generation etc. See the following listing.
class B __ far { ... } class A __far : B { ... } #pragma push #pragma DATA_SEG __FAR_SEG MY_FAR_RAM A a_far; #pragma pop