LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Default qualifier for 'Generate Function Tree'

Solved!
Go to solution

Hello,

 

since this is my first attempt to use the CVI feature for creating a function panel from an include file I am facing a very basic issue...

 

My problem is that in the 'Generate Function Tree' popup I need to specify a default qualifier. So far, however, I am not using any default qualifier, because a) I did not need them and b) I provide both 32 bit and 64 bit versions of the software. As I understand it, I would have to choose either __stdcall for 32 bit or __fastcall for 64 bit. In other words, a function panel will either work for 32 bit or for 64 bit programs? I guess this is a misunderstanding Smiley Wink

 

By the way, the tutorial (from 2014?) should be updated to reflect the actual popup panel of CVI2013...

0 Kudos
Message 1 of 6
(5,060 Views)
Solution
Accepted by topic author Wolfgang

You should be able to use __stdcall in your code, regardless of bitness. When you build a 64-bit version of your code, that qualifier is ignored (it will use fastcall instead), but its presence is harmless.

0 Kudos
Message 2 of 6
(5,010 Views)

Thanks Smiley Wink

 

...but why is it necessary to specify a qualifier at all? Function panels will only be used by CVI... I understand that for a DLL this information is required because 'everyone' can call it and hence the calling convention needs to be specified.

You see, lot's of room for learning Smiley Happy

0 Kudos
Message 3 of 6
(4,993 Views)

The reason I was asking is that "The default qualifier field in the Generate Function Tree dialog must be consistent with the default qualifier used in the source header file."

 

Because so far I did not define any calling convention in my include files (relying on the default settings) no function tree will be generated Smiley Sad

 

Certainly there is a reason for this requirement, if only I would understand it Smiley Wink Do people use different calling conventions in the same include file? Why do I need to specify a calling convention if it is ignored anyway (if building 64 bit programs)? Also, hard coding the calling convention seems to make the Build option superfluous....?

 

All in all, I don't understand / I am not convinced why I have to specify the calling convention (except to make the fp generation work)...

0 Kudos
Message 4 of 6
(4,934 Views)
Solution
Accepted by topic author Wolfgang

Unfortunately, all ll I can give you is my best guesses for why the qualifier is required, and you might not find them all that compelling.

 

1. This feature was adapted from what used to be an external tool, written a long time ago. The tool does not use compiler information. Instead, it parses the header file, using something akin to a brute-force method for doing so. This tool had (and has) some feature gaps as a result of this, and the requirement that a qualifier be specified in the prototype is one of them. My guess is that the presence of the qualifier made it easier for the parser to recognize the presence of a function prototype.

 

2. At the time that this tool was written, we only had 32-bit programs and, in the 32-bit world, it really was good programming practice for any public API to have the calling convention specified in each exported function, rather than rely on the compiler default -- since there could easily have been a mismatch between the default of the compiler that built the API and the default of the compiler that was using it. And since it was good programming practice to specify the calling convention, this limitation wan't considered to be all that burdensome. Of course, with header files that are to be used exclusively in 64-bit programs, that reasoning no longer applies.

 

Message 5 of 6
(4,879 Views)

Thanks Smiley Happy

0 Kudos
Message 6 of 6
(4,876 Views)