Developer Guide

Contents

Using the cdecl and stdcall Interfaces

stdcall functionality has been deprecated and will be removed in a future release of the product.
cdecl and stdcall calling conventions differ in the way how the stack is restored after a function call.
Intel® oneAPI Math Kernel Library
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® oneAPI Math Kernel Library
routines in your code as explained in the table below:
Interface Library
Calling
Intel® oneAPI Math Kernel Library
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

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.