As an alternative to the above method, you could use #pragma section <sectname> begin/end syntax if the function is defined in the same file as the #pragma define_section.
#pragma section FARSECT begin int farfunc(int i) { return i++; } #pragma section FARSECT end int main() { int j=0; j = farfunc(j); }
If the far function is defined in another module (an extern function), the #pragma define_section and __declspec or #pragma section must also be specified in the module containing the function definitions and must be identical to the #pragma define_section, __declspec, or #pragma section that references the far function.
====== main.c ====== #pragma define_section FARSECT ".farsect" far_abs RX __declspec(section "FARSECT") extern void farfunc(int); int main() { farfunc(3); } ======= file1.c ======= #pragma define_section FARSECT ".farsect" far_abs RX __declspec(section "FARSECT") extern void farfunc(int); void farfunc(int j) { return; }