Can't pass a callback function as a parameter to a DLL

N

NorrYtt

I am having a problem with passing a function as a parameter to my DLL
so it can call it back with updates. The DLL is written in LabWindows
CVI with some #ifdef 'C'-style wrappings. The application that calls
the DLL is in MS VC++ .NET.

It basically goes like this:

-There's a DLL initialization routine that the application will call.
This routine takes a function as a parameter. This is normally a (void
*) but I've tried a couple different ways, including typedef to what
the function should look like.
-After the initialize, the application calls an execute routine.

The application can call the DLL execute routine just fine, but I can't
get the DLL initialize to compile because of having to pass it a
function as a parameter. Here's the error message:

MyDLLInitialize: cannot convert parameter 1 from 'void
(DLLCallbackStruct)' to 'void (__cdecl *)(DLLCallbackStruct)' - None of
the functions with this name in scope match the target type

The line that generates it looks like:

MyDLLInitialize(MyDlg::CallbackUpdater);

I can't seem to get the name of the function properly passed to the DLL
initialize call. I can declare a typedef but I don't know how to
actually bind it to the function I want called. Everything else somehow
is met with compile errors. The closest I can get is the above
statement, and it has a __cdecl * mismatch, which I am not sure what
that means. Perhaps my DLL is C calling conventions and my application
is C++ calling conventions and it breaks down here with C++ strong
types? Or is it something totally different.

Thanks,
Ken
 
M

mlimber

I am having a problem with passing a function as a parameter to my DLL
so it can call it back with updates. The DLL is written in LabWindows
CVI with some #ifdef 'C'-style wrappings. The application that calls
the DLL is in MS VC++ .NET.

It basically goes like this:

-There's a DLL initialization routine that the application will call.
This routine takes a function as a parameter. This is normally a (void
*) but I've tried a couple different ways, including typedef to what
the function should look like.
-After the initialize, the application calls an execute routine.

The application can call the DLL execute routine just fine, but I can't
get the DLL initialize to compile because of having to pass it a
function as a parameter. Here's the error message:

MyDLLInitialize: cannot convert parameter 1 from 'void
(DLLCallbackStruct)' to 'void (__cdecl *)(DLLCallbackStruct)' - None of
the functions with this name in scope match the target type

The line that generates it looks like:

MyDLLInitialize(MyDlg::CallbackUpdater);

I can't seem to get the name of the function properly passed to the DLL
initialize call. I can declare a typedef but I don't know how to
actually bind it to the function I want called. Everything else somehow
is met with compile errors. The closest I can get is the above
statement, and it has a __cdecl * mismatch, which I am not sure what
that means. Perhaps my DLL is C calling conventions and my application
is C++ calling conventions and it breaks down here with C++ strong
types? Or is it something totally different.

Thanks,
Ken

This is probably off-topic here, but even if it's not, you'll probably
get a faster response in a Microsoft newsgroup. See this FAQ for what
is on-topic here and for a list of other (potentially better) places
you could post:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top