$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Cory Nelson (phrosty_at_[hidden])
Date: 2006-06-30 14:04:27
On 6/30/06, Stephen Torri <storri_at_[hidden]> wrote:
> I have a main file from my OpenGL program which contains global
> variables and the functions that are used by OpenGL as callback
> functions. For example:
>
>         int a;
>         float b;
>
>         void display ()
>         {
>                 .... display code calls ...
>         }
>
>         int main (int argc, char **argv)
>         {
>                     glutDisplayFunc( display );
>         }
>
> Now I thought I would put all the variables and functions into a class
> and use that in the main. Here is where I am getting stuck on the use of
> boost::function. I changed the code to look something like the
> following:
>
>         class MyMain {
>                 int a;
>                 float b;
>
>                 void display()
>                 {
>                         ... display code calls ...
>                 }
>         }
>
>         int main (int argc, char **argv)
>         {
>                 MyMain m_ref;
>                 boost::function<void()> disp_func = boost::bind ( &MyMain::display, &m_ref );
>                 glutDisplayFunc ( disp_func );
>         }
>
> What I am getting back from the g++ compiler is the following error message:
>
> error: cannot convert `boost::function<void ()(), std::allocator<void> >' to `void (*)()' for argument `1' to `void glutDisplayFunc(void (*)())'
>
> Any ideas where I am going wrong?
You are passing a function object to a C function which expects a
function pointer.  A boost::function can not be converted into a
function pointer.
> Stephen
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://listarchives.boost.org/mailman/listinfo.cgi/boost-users
>
-- Cory Nelson http://www.int64.org