473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
1 2630
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roy Yao | last post by:
Hello, I need to pass a pointer to a callback function to the lower level modules. But the function is thought to be a virtual member one. How can I get the real address of the virtual...
0
by: Thomas Mlynarczyk | last post by:
Hi, I want to process the output of a script line by line before sending it out. I thought, ob_start() with a callback function would do the job if the callback function was called for every...
4
by: Kyku | last post by:
Hello all, I'm in a process of writing a small Linux C++ program for discovering repeaded files over a filesystem. One part of this task is traversing a directory structure. This is done by the...
12
by: semedao | last post by:
Hi all, someone know if I can use the IAsyncResult.IsCompleted Property of IAsyncResult that return from Socket.Beginxxx methods to determine if the Endxxx method already called perior or not ? I...
2
by: MyCrystalGift | last post by:
Hi, I have an old C++ GUI Application CPPAPP.exe that calls a C DLL library RULE.DLL through a C++ class wrapper LoadRule.CPP. Now I need to call the C DLL RULE.DLL from C# GUI application...
6
by: JDT | last post by:
Hi, Can we pass a member function in a class as a callback function? Someone instucted me that I can only use a static functon or a global function as a callback. Your help is appreciated. JD
2
by: Evan Burkitt | last post by:
Hi, all. I have a Windows DLL that exports a number of functions. These functions expect to receive a pointer to a callback function and an opaque void* parameter. The callback functions are...
8
by: Neviton | last post by:
Is it possible ? There is any work around? Thanx
5
by: Jef Driesen | last post by:
I have a C DLL that I want to use from a C# project. The C header file contains these declarations: typedef void (*callback_t) (const unsigned char *data, unsigned int size, void *userdata);...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.