LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Labwindows CVI 2010 and GetProcessAddress()

Solved!
Go to solution

I am using Labwindows CVI 2010 v10.0.1 after upgrading from version CVI 2010 v10.0.0. After the upgrade, I have a compile error from a statement that compiles just fine in the previous version. The error is:

 

"Operands of = have illegal types 'pointer to __stdcall int function(int,pointer to char,pointer to char,pointer to char,int,pointer to char,pointer to char)' and 'FARPROC'."

 

What causes this error is the following statement in the code:

 

my_FP = GetProcAddress(dll_handle, "DLL_FUNCT");

 

and the definition of my_FP is:

 

int __stdcall (*my_FP)(int x, char y[], char z[], char *m, int g, char A[], char B[]);

 

(function names and parameters have been changed for simplicity)

 

As I said, this line compiles just fine in 10.0.0, but not in 10.0.1. Is there a specific update to the compiler that will cause this error? What can be done to fix this?

 

Thank you very much for your time and help.

0 Kudos
Message 1 of 4
(3,620 Views)

Ok as an update, I declared the function pointer as a typedef and casted the result of GetProcAddress() and that compiles and works fine. However, I still wonder what has changed and if this is going to affect other code that has not been updated.

0 Kudos
Message 2 of 4
(3,617 Views)
Solution
Accepted by topic author psokom40

You're correct. This was caused by a change in CVI Windows SDK headers that took place in version 2010 SP1. The change was associated with bug fix #275934. Unfortunately, this bug fix introduced this undesirable side effect of requiring a cast for any function that returns a FARPROC function poinrter (such as GetProcAddress). Upon further reflection, this side effect is unacceptable, and needs to be corrected in the next release. This is being tracked internally with bug ID #336341.

 

I'm really sorry for this inconvenience. Until the problem is resolved, using the typedef & cast solution that you already implemented is a valid workaround.

 

An alternative workaround, in case you're worried about other projects, or other functions, where this error might also pop up, is to edit CVI2010\sdk\include\windef.h and replace the following FARPROC definitions (in lines 226 and 230, respectively):

 

typedef INT_PTR (FAR WINAPI *FARPROC)(void);

typedef int (FAR WINAPI *FARPROC)(void);

 

with:

 

typedef INT_PTR (FAR WINAPI *FARPROC)();

typedef int (FAR WINAPI *FARPROC)();

 

Doing this will avoid the problem throughout a given installation of CVI.

 

Luis

NI

0 Kudos
Message 3 of 4
(3,582 Views)

Thank you very much for your response Luis. I will keep track of the update in the new release. For now, it is acceptable to use either workaround. 

 

Thanks again,

Paul

0 Kudos
Message 4 of 4
(3,570 Views)