Linkage Keywords (OS/2, Windows)

Use linkage keywords to set linkage conventions for function calls. Each linkage convention has a corresponding keyword that you can use with a function name to set the convention for that function. The keywords are:

Keyword(s) Description
_Optlink IBM C and C++ Compilers default linkage for C++ non-member functions
_System System linkage
__stdcall Standard calling convention
__cdecl C calling convention
_Pascal 32-bit _Pascal linkage
_Far32 _Pascal 32-bit far _Pascal linkage
_Far16 _Cdecl 16-bit __cdecl linkage
_Far16 _Pascal 16-bit _Pascal linkage
_Far16 _Fastcall 16-bit _Fastcall linkage
 
You can use the linkage keywords at any language level. To set the calling convention for a function, place the linkage keyword immediately before the function name. For example,
   int _System deborah(int);
   char (* _Far16 _Cdecl donna)(int);

Linkage keywords take precedence over the compiler options that set calling conventions. If you specify conflicting linkage types for a function using both a #pragma linkage directive and a keyword, an error message is generated and your program will not compile.

Note: Using a keyword is generally quicker and easier than using a #pragma linkage and they let you declare both the function and its linkage type in one statement. Because the #pragma linkage directive is obsolete in this release of IBM C and C++ Compilers, linkage keywords are the preferred method for setting the calling conventions.

#pragma linkage is not supported at all for C++ functions.