LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Suppressing compiler-dependent warning when explicitly linking to DLLs?

Hi, I'm creating a DLL in CVI 2009 that I want to link explicitly in an application that is also build in CVI 2009 using LoadLibrary() and GetProcAddress().  This is working fine for linking of functions, but for global variables I get a warning when building the application:

 

"Warning: Conversion from 'FARPROC' to 'pointer to int' is compiler-dependent."

 

What I'm doing is, in the DLL, in the exports .h file I define:

extern int nnt_test;

 

And in the DLL's .c file I declare the global like:

int nnt_test = 465;

 

And in the application's .c file I access the variable like such (after loading the library):

int *g_test_varptr;

g_test_varptr = (int*)GetProcAddress(g_nnt_dllinst, "nnt_test");

 

This is the line where I get the compiler warning.  This method seems to work, as the application can see the value of the variable (465) and modify it and whatever it needs to do.  I'm not too terribly concerned if this doesn't work in other compilers as I don't plan on using an external compiler at this point.  Is there any way to suppress this warning so I don't have it popping up every time I build, or a better way of explictly linking global variables (other than creating Get/Set functions and linking those)?  Thanks!

0 Kudos
Message 1 of 2
(2,832 Views)

To answer my own question, recasting as void* first seems to elimate the compiler warning, i.e.:

 

g_test_varptr = (int*)(void*)GetProcAddress(g_nnt_dllinst, "nnt_test");

 

I just need to sit and think about these things for longer before I post. Smiley Happy

0 Kudos
Message 2 of 2
(2,825 Views)