LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

What is __stdcall appears in the function header

Hi all,

I'm using CVI7.1+TestStand 3.0.

TestStand creates a function with the following header:

void __declspec(dllexport) __stdcall OpticalParameterTest(CAObjHandle seqContextCVI,double measurements[],char reportText[1024], short *errorOccurred, long *errorCode, char errorMsg[1024]);

Some of my other functions do not have the __stdcall which made me wonder about it. I may have copied the other functions from another project. At the same time, can you explain what does the __declspec(dllexport) means?

Thanks
Rafi
0 Kudos
Message 1 of 4
(4,569 Views)
Hello Rafi2003,

__stdcall and __cdecl are two calling conventions available in CVI. When functions are called from your application, the arguments are placed in the stack in a particular order. The calling convention specifies whether the calling function or the function itself is responsible for cleaning up this stack. You can imagine a stack overflow situation occuring if both your application and the function expects the other to clean up the stack. More information on the two calling conventions can be found in the following KnowledgeBase.

Regarding your second question, __declspec(dllimport) and __declspec(dllexport) are a few of the import/export qualifiers CVI supports. An import qualifier informs the compiler that the symbol is defined in a DLL. Declarations of variables imported from a DLL require import qualifiers, but function declarations do not.

An export qualifier is relevant only in a project for which you set the target type as Dynamic Link Library. The qualifier can be on the declaration or definition of the symbol, or both. The qualifier instructs the linker to include the symbol in the DLL import library.

More information about these two topics can be location in CVI Help under Programmer's Reference and in the following tutorial: FAQ: Using Dynamic Link Libraries with LabWindows/CVI.

Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 4
(4,564 Views)
Hi Wendy,

Thank you very much for this clarification.

As a conclusion, may I say that if call my dll ONLY from the TestStand and no exportation to other platforms, then, I need to specify neither __stdcall nor __cdecl ?

Or, is it recommended to use __stdcall as a standard? (or may by __cdecl as a standard?)

Thanks
Rafi
0 Kudos
Message 3 of 4
(4,551 Views)
Hi again,

Another question in the same issue:

In the 'Target Settings' for the dll with the functions called by TestStand, the export is marked 'export What: Symbols Marked for export'.

In other dlls which include functions not called by TestStand it is set to: 'export What: Include File symbols'. In this case i also mark the *.h files associated with the dll.
1) Is this is the correct way to do it?
2) Is there any need to specify calling convention for this dll too?

Thanks
Rafi
0 Kudos
Message 4 of 4
(4,551 Views)