Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Motif and C++

Posted on 1997-06-19
2
Medium Priority
?
782 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 400 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

664 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