z/OS Language Environment Writing Interlanguage Communication Applications
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Declaring C to C++ ILC

z/OS Language Environment Writing Interlanguage Communication Applications
SA38-0684-00

If a C function invokes a C++ function or a C++ function invokes a C function, all entry declarations are contained solely within the C++ source. No special declaration is required in the C code.

For C to C++ ILC, the C++ extern "C" linkage specification lets the C++ compiler generate parameter lists for C or accept parameter lists from C.

The extern "C" linkage specification has the following format:

extern "C" {declaration}

declaration is a valid C++ prototype of the C function(s) being called by C++, or the C++ routine being called by C. The braces { } are not required if only one declaration is specified.

If your C or C++ application is compiled with XPLINK or LP64 (which implies AMODE 64 XPLINK), the linkage and parameter passing mechanisms for C and C++ are identical. If you link to a C function from a C++ program, you should still specify extern "C" to avoid name mangling.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014