Solved

Motif and C++

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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: 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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

617 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