|
Boost Users : |
Subject: Re: [Boost-users] [function] dynamic function factory
From: joel falcou (joel.falcou_at_[hidden])
Date: 2010-03-10 14:51:38
Alexander Lamaison wrote:
> I'm trying to write a little wrapper round Windows GetProcAddress (dlsym
> equivalent?) that takes a function name by string, loads it dynamically and
> returns it as a boost::function. I'm having trouble getting my code to
> accept the same type of signatures as boost::function.
>
> E.g.:
>
> template<typename Signature>
> boost::function<Signature> proc_address(
> hmodule hmod, const std::string& name)
> {
> return boost::function<Signature>(GetProcAddress(hmod, name.c_str());
> }
>
> Where GetProcAddress returns a int (*)() which you cast to the function
> signature you're expecting. The problem is that when I call:
>
> boost::function<int (int)> func;
> func = proc_address<int (int)>(hmod, "GetKeyboardInfo");
>
> The compiler (MSVC 2005) complains about a ) after the int:
>
> error C2144: syntax error : 'int' should be preceded by ')'
> error C2563: mismatch in formal parameter list
>
IIRC MSVC has problem with the int() notation try the portabel function
usage:
boost::function<int,void> or something
-- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net