Boost logo

Boost Users :

From: Erzengel Des Lichtes (erzengel.des.lichtes_at_[hidden])
Date: 2008-07-30 20:02:57


Hello, I'm having an issue with boost::function in Visual Studio.NET
2005. In the following program:

#include <boost/function.hpp>

void SomeFunc(int* Blah)
{
   //DoSomething
}

int __cdecl main(int argc, char* argv[], char* envp[])
{
   boost::function<void(*)(int*)> MyFunc;
}

I get the following error message:

(Project Directory)\boostfunctest.cpp(11) : error C2079: 'MyFunc' uses
undefined class 'boost::function'
       with
       [
           Signature=void (__stdcall *)(int *)
       ]

If I leave off the "(*)" it will compile, but this is just a
simplified version of my real problem.
The main reason this is a concern is I have a templated function that
looks like this:
template<typename Signature>
boost::function<Signature> GetFunction(Signature ToCall);

Which I intend to use to record and "play back" certain function
calls. However, when it sees the signiture from the function pointer,
it ALWAYS sees it as 'void(*)(int*)' (for example), rather than
'void(int*)' and fails to compile. For example, the following program:

#include <boost/function.hpp>

void SomeFunc(int* Blah)
{
   //DoSomething
}

template<typename Signature>
boost::function<Signature> GetFunction(Signature ToCall)
{
   //TODO: Check if function is in list, add it to list, etc.
   return boost::function<Signature>(ToCall);
}

int __cdecl main(int argc, char* argv[], char* envp[])
{
   GetFunction(SomeFunc);
}

I get:
(Project Directory)\boostfunctest.cpp(17) : error C2027: use of
undefined type 'boost::function'
       with
       [
           Signature=void (__stdcall *)(int *),
           Allocator=std::allocator
       ]

So, anyone have any idea what's wrong and how to fix it? Thanks for any help.

Note: I am compiling with /Gz, but compiling with /Gd and /Gr merely
changes the "__stdcall" to "__cdecl" and "__fastcall" in the error
messages, respectively, so it does not seem to matter which calling
convention is used.

-- 
Erzengel des Lichtes
光の大天使 (Hikari no Daitenshi)
Archangel of Light

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