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
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
func; func = proc_address (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
On Wed, 10 Mar 2010 20:51:38 +0100, joel falcou wrote:
Alexander Lamaison wrote:
template<typename Signature> boost::function<Signature> proc_address( hmodule hmod, const std::string& name) { return boost::function<Signature>(GetProcAddress(hmod, name.c_str()); }
IIRC MSVC has problem with the int() notation try the portabel function usage:
boost::function
or something
Unfortunately, I can't write proc_address
Alexander Lamaison wrote:
Unfortunately, I can't write proc_address
because it only has the single Signature template paramter. I notice that the boost 'portable syntax' would be boost::function*X* . I don't have numbered versions of proc_address. Is this what I need to get it to work?
I think so -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
On Wed, Mar 10, 2010 at 1:09 PM, joel falcou
Alexander Lamaison wrote:
Unfortunately, I can't write proc_address
because it only has the single Signature template paramter. I notice that the boost 'portable syntax' would be boost::function*X* . I don't have numbered versions of proc_address. Is this what I need to get it to work? I think so
That should not be necessary, VS2k5 supports the modern usage just fine. I actually have code that does exactly what you are trying to do that works just fine.
On Wed, 10 Mar 2010 21:31:06 -0700, OvermindDL1 wrote:
On Wed, Mar 10, 2010 at 1:09 PM, joel falcou
wrote: Alexander Lamaison wrote: Unfortunately, I can't write proc_address
because it only has the single Signature template paramter. I notice that the boost 'portable syntax' would be boost::function*X* . I don't have numbered versions of proc_address. Is this what I need to get it to work? I think so
That should not be necessary, VS2k5 supports the modern usage just fine. I actually have code that does exactly what you are trying to do that works just fine.
Would you be able to post a snippet showing the declaration? Thanks. Alex
participants (3)
-
Alexander Lamaison
-
joel falcou
-
OvermindDL1