LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

function pointer to library function question

Hi,
I can't figure out how to set function pointers to functions defined in a
library. I'm doing the following:
I've an instrument structure which has a member
void (*out)(int instr_nr, int data_type);

When the function pointer is initialized in the standard way:
instr-> out = set_instrument;
and I call instr->out(nr, kINT32);
It works when set_instrument is defined in a c file which is part of the
project.

I would like to put all these instrument C files in one generated library
instruments.lib but this creates several problems.
When I use LoadExternalModule("instruments.lib") and
instr-> out = GetExternalModuleAddr (module_id, "set_instrument", &status);
I see that the function pointer is initialized (no error), but the call to
instr-> out crashes.

Using __stdcall before the set_instrument creates problems when
initializing; well, don't know how to force the function pointer in the cvi
compiler to recognize this with whatever linker option.
instr-> out = __stdcall set_instrument doesn't work.
Any ideas how to do this?
Taco
0 Kudos
Message 1 of 2
(2,997 Views)

Did you try changing the definition of your pointer like this:

 

__stdcall void (*out_s) (int instr_nr, int data_type); 

 

JR

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