Solved

Motif and C++

Posted on 1997-06-19
2
776 Views
Last Modified: 2013-12-26
I am trying to figure out Motif using C++.  I am having a difficult time getting callbacks to work.  I imagine there is some goofy pointer thing happening but I am not sure what.

I have a class MainMenu.  In that class I create some xmPushButtonGadgets.  Now I am trying to set up a call back
here is some code snippets
---
//MainMenu.h
...
protected:
void open(Widget, XtPointer, XtPointer);
...
------
//MainMenu.C

... Widget button;
  button=XtVaCreateManagedWidget("Open",xmPushButtonGadgetClass,_filePullDown,NULL);
  XtAddCallback(button,XmNactivateCallback,&MainMenu::open,NULL);
...

I can not figure out what to pass in for the callback function name.  Everything I have tried generates some goofy error.  This generates the following error

"MainMenu.c++", line 67: error(3252): argument of type
          "void (MainMenu::*)(Widget, XtPointer, XtPointer)" is incompatible
          with parameter of type
          "XtCallbackProc)(Widget, XtPointer, XtPointer)"
    XtAddCallback(button,XmNactivateCallback,&MainMenu::open,NULL);

Thanks

Thought you might be interested to know that I can rack up all the points I want in the advertiser quiz thing by just hitting the back button.
0
Comment
Question by:micah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
lockhart earned 100 total points
ID: 1293545
You may need to typecast your callback to be an XtCallbackProc. This is a C++ thing, in C it wouldn't particularly care. You also don't need the "&" before your routine name. By definition, a routine name is an address if it isn't followed by parens just like a class name is considered to be a type declaration for an instance if it isn't followed by parens.

Just removing the "&" may reduce this to a warning, but something like:

XtAddCallback (button,
               XmNactivateCallback,
               (XtCallbackProc)MainMenu::open,
               NULL);

will probably let the compiler stick the proper address into the activate callback slot.

Mike
0
 
LVL 4

Expert Comment

by:jos010697
ID: 1293546
If you want a nice C++ environment for Motif, mail
rvloon@xs4all.nl or ronald@and.nl. He's the maintainer
of the Motif++ layer. (there's a mailinglist for this stuff too)

kind regards,

Jos aka jos@and.nl (yes, ronalds desk is opposite of mine ;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 76
either24  challenge 19 110
scoreUp challenge 14 74
listing all the respondents to a twitter feed - Java 5 49
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Suggested Courses

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question