Using _cdecl and _stdcall Calling Conventions in the Same LabWindows™/CVI™ Project

Updated Dec 22, 2017

Reported In

Software

  • LabWindows/CVI Full

Issue Details

I am trying to call two .dlls in my LabWindows™/CVI™ project and they are built using different calling conventions. One .dll is built using the cdecl calling convention and the other is built using the stdcall (WINAPI) calling convention. Can I use both of them in the same LabWindows/CVI project?

Solution

You can use both calling conventions in the same LabWindows/CVI project. To set the default calling convention you can go to Options >> Build Options>> Default calling convention seen in Figure 1.


This is the setting used if no calling convention is specified. In order to change the calling convention for a specific function, you can specify the calling convention when making the function call. Calling conventions can include _stdcall or _cdecl, which is inserted directly before the function.

Example: FUNCTION_API int  _cdecl Function (int x)  

Note: If you do not specify the correct calling convention you will get a Fatal Run-Time Error containing a General Protection Fault.

WAS THIS ARTICLE HELPFUL?

Not Helpful