Admin Production ni-theme
Current Publication

Calling Conventions

LabWindows/CVI

Calling Conventions

You can use the following calling convention qualifiers in function declarations.

cdecl (32-bit projects only)
_cdecl (32-bit projects only)
__cdecl (recommended; 32-bit projects only)
_stdcall (32-bit projects only)
__stdcall (recommended; 32-bit projects only)
__fastcall (64-bit projects only)

In Microsoft Visual C/C++, the calling convention normally defaults to __cdecl if you do not use a calling convention qualifier. You can, however, set options to cause the calling convention to default to __stdcall. LabWindows/CVI behaves the same way. For 32-bit projects, you can set the default calling convention to either __cdecl or __stdcall in the Build Options dialog box. When you create a new project, the default calling convention is __cdecl.

In the __cdecl calling convention, the calling function is responsible for cleaning up the stack. Functions can have a variable number of arguments in __cdecl.

In the __stdcall calling convention, the called function is responsible for cleaning up the stack. Functions with a variable number of arguments do not work in __stdcall. If you use the __stdcall qualifier on a function with a variable number of arguments, LabWindows/CVI does not honor the qualifier. All compilers pass parameters and return values, except for floating point and structure return values, in the same way for __stdcall functions.

National Instruments recommends you use the __stdcall calling convention for all functions exported from a DLL, except functions with a variable number of arguments. Microsoft Visual Basic and other non-C Windows programs expect DLL functions to be __stdcall.