Specifying the Linkage Convention
Use the #pragma linkage and #pragma argument directives to specify the linkage convention. See Table 1 and Accessing ILE C Procedures from Any ILE Program for more information on using these directives.
When specifying linkage conventions, consider the following C++
characteristics:
- A C++ program uses the standard OS linkage calling convention. Use the #pragma linkage directive to flag the function call as an external program call.
- When you call C++ functions, you must make sure that the sender
and receiver both agree on the type of parameter being passed, whether
it is by pointer or by value, and whether parameters are widened.
For example, if the function you are calling was declared as
extern "C nowiden", you must use the#pragma argument(func, nowiden)directive in the function declaration in ILE C. - You can declare a C++ function as external by explicitly declaring
the function within the C++ code using either
extern "C"orextern "C nowiden". You can add#ifdefstatements to the function declarations in the header files used by both C and C++ modules, as shown in Figure 1.
#ifdef __cplusplus
extern "C" {
#endif
function declarations
#ifdef __cplusplus
}
#endif
Note: These statements are declared with C linkage.