0

I'm trying to create a menu using ncurses, I found some useful code and help online, but the code has errors in it. And I can't figure out why I'm generating this error. On top of all this, theres no way I'll be able to use the information I've found until I figure out how to correct this.

here is the code generating the error with a comment pointing to the specific line

while((c = getch()) != KEY_F(1))
   {       switch(c)
     {case KEY_DOWN:
        menu_driver(my_menu, REQ_DOWN_ITEM);
        break;
     case KEY_UP:
       menu_driver(my_menu, REQ_UP_ITEM);
       break;
     case 10: /* Enter */
       {ITEM *cur;
       void (*p)(char *);

       cur = current_item(my_menu);
       p = item_userptr(cur);  //<<<<<<< This line is generating this error:
           //main.cpp:70: error: invalid conversion from `void*' to `void (*)(char*)'

       p((char *)item_name(cur));
       pos_menu_cursor(my_menu);
       break;
       }
       break;
     }
   }

from what I've read online item_userptr() will return a void*

any help would be appreciated

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Dewey1040
0

As long as you are sure that current_item returns a function pointer, you can write:
p=reinterpret_cast<void(*)(char*)>(item_userptr(cur));

0

Thanks, I might end up needing help beyond this but I think I got it working.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.