Solved

Motif and C++

Posted on 1997-06-19
2
768 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
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 76
isEverywhere  challenge 19 64
wordcount challenge 11 76
Sed question 2 48
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now