Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 855297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:03:16+00:00 2026-05-15T08:03:16+00:00

I was successfully to finally be able to use TUI header from PDcurses library

  • 0

I was successfully to finally be able to use TUI header from PDcurses library in my C++ project in a previous post here.

now in my class I am including the C header:

#include "tui.h"

tui is in C and has this definition for menu:

typedef struct 
{
    char *name; /* item label */
    FUNC  func; /* (pointer to) function */
    char *desc; /* function description */
} menu;

so in MainView.cpp I have:

void sub0()
{
    //domenu(SubMenu0);
}

void sub1()
{
    //domenu(SubMenu1);
}


void MainView::showMainMenu()
{
    menu MainMenu[] =
    {
        { "Users", sub0, "Manage Users" },
        { "Accounts", sub1, "Manage Accounts" },
        { "Items", sub1, "Manage Items" },
        { "Staff", sub1, "Manage Staff" },
        { "", (FUNC)0, "" }  
    };
    startmenu(MainMenu, "Library System 1.0");
}

this is working as expected.

The problem is that i need to make calls on my class methods in sub0() and sub1().

I tried to define C++ methods for my class to try and replace sub0 and sub1
with:

void MainView::sub0()
{
    //domenu(SubMenu0);
}
void MainView::sub1()
{
    //domenu(SubMenu1);
}

the compiler is throwing this error:

error C2440: 'initializing' : cannot convert from 'overloaded-function' to 'FUNC'
None of the functions with this name in scope match the target type

what is the best way of passing those function pointers to the C code and get rid of that error?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:03:16+00:00Added an answer on May 15, 2026 at 8:03 am

    C++ class objects have a “this” pointer, which is sort of invisibly passed as the first argument to a class member function. That means you can’t use a non-static member function for a C-style function pointer that takes 0 arguments.

    So solve this, you have a few choices. I’d need more detail before telling you which one to go with.

    • Make the functions you want to use in the C code static.
    • Use boost or tr1 or some other C++ library that allows binding member functions with their this pointer. With boost, this would look like:

      { "Users", boost::bind(&MainView::sub0, this), "Manage Users" },
      
    • You might be able to modify your code to pass around a reference to the class object along with these function pointers. If so, you can then invoke your callbacks directly on the object you want. It looks like you’re dealing with a window manager though, and so you probably won’t be able to make the changes needed for this approach to work.

    • Probably what you will end up doing is some sort of work around, involving storing the pointer to the object you’re using somewhere and then writing small stub functions which access this pointer and then call a member function on it. Some (dare I say, most) window managers allow you to include a pointer to arbitrary data with the callback for this purpose.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Successfully used jquery-infinite-carousel in the past but for my current project I need it
I successfully installed the latest QuantumGrid from DevExpress, but I've never worked with this
Having successfully gotten a sample program working, I'm now starting to do Real Work
I have successfully connected to an Oracle database (10g) from C# (Visual Studio 2008)
Has anyone successfully talked profibus from a .NET application? If you did, what device/card
I finally thought I had found a way to acutally use excel productively but
After following several tutorials I was finally able to take my existing, non-Git-Repository XCode
I am trying to use the axis-java2wsdl ant task to create a wsdl from
I've finally finished my killer app and now I've got a bit of an
I am writing an iPhone application and I have finally decided to use RestKit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.