Developer Guide

Contents

Using the cdecl and stdcall Interfaces

cdecl and stdcall calling conventions differ in the way how the stack is restored after a function call.
Intel® MKL
supports both conventions in its IA-32 architecture implementation through the
mkl_intel_c[_dll].lib
and
mkl_intel_s[_dll].lib
interface libraries. These libraries assume the defaults of different compilers, which also differ in the position of the string lengths in the lists of parameters passed to the calling program, as explained in the following table:
Library for Static Linking
Library for Dynamic Linking
Calling Convention
Position of String Lengths in Parameter Lists
mkl_intel_c.lib
mkl_intel_c_dll.lib
cdecl
At the end
The defaults of Intel® C++ and Intel® Fortran compilers
mkl_intel_s.lib
mkl_intel_s_dll.lib
stdcall
Immediately after the string address
The defaults of Compaq Visual Fortran* (CVF) compiler
To avoid errors, ensure that the calling and called programs use the same calling convention.
To use the cdecl or stdcall calling convention, use appropriate calling syntax in C applications and appropriate compiler options for Fortran applications.
If you are using a C compiler, to link with the cdecl or stdcall interface library, call
Intel® MKL
routines in your code as explained in the table below:
Interface Library
Calling
Intel® MKL
Routines
mkl_intel_c
[_dll].lib
Use the following declaration:
<type> name( <prototype variable1>, <prototype  variable2>, .. ); 
mkl_intel_s
[_dll].lib
Call a routine with the following statement:
extern __stdcall name( <prototype variable1>, <prototype variable2>, .. );
If you are using a Fortran compiler, to link with the cdecl or stdcall interface library, provide compiler options as explained in the table below:
Interface Library
Compiler Options
Comment
Intel® Fortran compiler
mkl_intel_c[_dll].lib
Default
mkl_intel_s[_dll].lib
/Gm
or
/iface:cvf
/Gm
and
/iface:cvf
options enable compatibility of the CVF and Powerstation calling conventions
CVF compiler
mkl_intel_s[_dll].lib
Default
mkl_intel_c[_dll].lib
/iface=(cref, nomixed_str_len_arg)

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804