From: Philip Nash (philip.nash_at_[hidden])
Date: 2001-10-30 07:24:29
> From: "Philip Nash" <philip.nash_at_[hidden]>
> > I'm using MSCV (6) and am unable to bind to a function that is
> declared as
> > using the __stdcall calling convention (eg, any Windows API function). I
> > a compiler error along the lines of, "cannot convert parameter 1 from
> > <function ptr not using __cdecl> to <function ptr using __cdecl>"
> > Should this be possible? If not is there a workaround (other
> than creating
> > forwarding function by hand for every __stdcall function I want to bind
> > to!)?
> It's possible. Treat the __stdcall function as a function object
> and use the
> general bind<R>(f, ...) syntax.
> Here's an example from my code:
> class dialog
> HWND get() const;
> bool isDialogMessage(MSG * msg)
> std::set<dialog *> const & instances = ::instances();
> // see if the message is for a modeless dialog box
> return std::find_if(instances.begin(), instances.end(),
> boost::bind<BOOL>(::IsDialogMessage, boost::bind(&dialog::get,
> _1), msg)) !=
> It would probably be an interesting extension to add the
> necessary __stdcall
> overloads to bind but this is a dangerous path. :-)
Hmm, interesting - thanks for the reply and example, btw.
Are you compiling that with MSVC, though?
I did actually try that (if I have understood correctly).
I have reduced my attempt down to this example:
int __stdcall AddFn( int x, int y )
boost::bind<int>( &AddFn, 2, 3 ); // compiler error here
And I am still getting a compiler error "type 'int' unexpected" ???
As for the "interesting extension", could it be accomplished as an adapter?
You obviously wouldn't want __stdcall, or other proprietry extensions
polluting the bind interface, but as a seperate adapter...?
Thanks for your help,
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk