Admin Production ni-theme
Current Publication

Calling Convention for Exported Functions

LabWindows/CVI

Calling Convention for Exported Functions

If you intend for only C or C++ programs to use your DLL, you can use the __cdecl convention to declare the functions you want to export. However, if you want your DLL to be callable from environments such as Microsoft Visual Basic, you must declare the functions you want to export with the __stdcall calling convention. You must do this by explicitly defining the functions with the __stdcall keyword, regardless of whether or not you make __stdcall the default calling convention for your project. You must use the __stdcall keyword in the declarations in the include file you distribute with the DLL.

Other platforms, such as UNIX, do not recognize the __stdcall keyword. If you work with source code that you might use on other platforms, you must use a macro in place of __stdcall. The cvidef.h include file defines the DLLSTDCALL macro for this purpose.

The DLLSTDCALL macro is used in the following examples:

int DLLSTDCALL MyIntFunc (void);
char *DLLSTDCALL MyStringFunc (void);

Note  You cannot use the __stdcall calling convention on functions with a variable number of arguments. Consequently, you cannot use such functions in Microsoft Visual Basic.