Language mixing - linkage


Different compilers on different operating systems use different conventions in generating symbolic references to functions. The following examples illustrate the most widespread convention.

FORTRAN - most UNIX flavours and many others

For a function or subroutine, the symbol is generated by taking the function name, converting to lower case and appending an underscore.

e.g. The compiler will generate the symbol vadd_ for the FORTRAN subroutine VADD (or VAdd or vadd or...).

C - universal?

The symbol is generated using the function name directly i.e. without case conversion.

e.g. The compiler will generate the symbol printf for the function printf and the symbol Printf for the function Printf.

C++ - universal?

The symbol is generated from the function and class name without case conversion and appending the argument type and number information in an encoded form.

You don't want to see an example!

"C" linkage can be used using the extern "C" {} notation to facilitate mixing of C++ with C or FORTRAN.