By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,115 Members | 898 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,115 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Jun 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
No*****@gmail.com wrote:
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-lit...t.html#faq-5.9

Cheers! --M

Jun 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.