Compiling OO graphics

I have an existing app which has been built with PhAB on top of C++ code. Now I am trying to add a dialog module and stay consistent with the C++ coding style, and I have problems getting it to compile.

I’m adding a dialog called GetDataDlg that is instantiated in response to a menu selection. The dialog has three widgets, and the only callbacks I’m concerned about at present are a setup function called before realizing the dialog, an item selection callback, and an action function to be called upon a button click. The functions are all declared and defined in a class GetDataDlg, in the files GetDataDlg.h & GetDataDlg.cpp.

I have had this all compiled and working in the straight C code for which PhAB generates stubs.

Now when I try to compile I get the following messages:
abevents.h:149: assuming & on GetDataDlg::gd_getSelection' abevents.h:149: converting from int (GetDataDlg::*)(PtWidget_t *, ApInfo_t *, P
tCallbackInfo_t )’ to int (*)(PtWidget_t *, ApInfo_t *, PtCallbackInfo_t *)' abevents.h:149: assuming & on GetDataDlg::gd_action’
abevents.h:149: converting from int (GetDataDlg::*)(PtWidget_t *, ApInfo_t *, P tCallbackInfo_t *)' to int (
)(PtWidget_t *, ApInfo_t *, PtCallbackInfo_t *)’

I have looked at abevents.h (which is a generated file), and the line in question looks like:
static const ApEventLink_t AbLinks_GetDataDlg[] = {
{ 8, 0, 0L, 0L, 0L, NULL, NULL, “PtGetDataList”, 23010, GetDataDlg::gd_getSelection, 0, 0, 0, 0 }
{ 10, 0, 0L, 0L, 0L, NULL, NULL, “PtCancel”, 2009, NULL, 0, 0, 0, 0, },
{ 8, 0, 0L, 0L, 0L, NULL, NULL, “PtPerfActionBtn”, 2009, GetDataDlg::gd_action, 0, 0, 0, 0 }
{ 0 }

I can’t see that these entries differ in form or substance from other entries that compile just fine.

Can anyone shed any light on this conundrum?

Randy C.

so the other functions are in classes as well?

I am not an OO expert so I do not really understand how this is supposed to work. I mean, having a function in the class you would need an instance of your class to call the callback-function, i.e. something like GetDataDlg my_dlg; my_dlg.gd_getSelection(widget, foo, bar);Right?
I don’t know whether PhAB is able to handle functions that way.

The alternative would be to declare your functions to be static, but I think this would violate with the structure of your ApEventLink_t because this demands for a ApCallbackF_t function and this is defined as int (Ap.h):/* Callback function type */ typedef int ApCallbackF_t( PtWidget_t *widget, ApInfo_t *data, PtCallbackInfo_t *cbinfo );
So could you please post some of the working code with class functions?

OK, here’s an extraction of code that compiles.

This first sample is the setup callback, defined in the file HomeDlg.cpp:

int HomeDlg::setup( PtWidget_p wdgt, ApInfo_t* apinfo, PtCallbackInfo_t* cbinfo )
if ( apinfo->reason == ABR_PRE_REALIZE )
return _instance->preRealizeSetup
(wdgt, apinfo, cbinfo );
return _instance->postRealizeSetup( wdgt, apinfo, cbinfo );

This is the extract of the header, HomeDlg.h, where the HomeDlg class is declared.

class HomeDlg

// some stuff

// setup function - called before module is displayed
static int setup( PtWidget_p instance, ApInfo_t* apinfo,
PtCallbackInfo_t* cbinfo );
// all menu items callback to this - dispatches to member methods
static int action( PtWidget_p wdgt, ApInfo_p api, PtCBI_p cb );
// invoked before menu is displayed
int preRealizeSetup( PtWidget_p w, ApInfo_t* info,
PtCallbackInfo_t* cbinfo );
// invoked right after menu is displayed
int postRealizeSetup( PtWidget_p w, ApInfo_t* info,
PtCallbackInfo_t* cbinfo );

I’m probably asking an unanswerable question, because there are so many possible ways to go off in the weeds. But this is working code, and I followed this model in creating my new dialog, but it won’t compile – see the errors in the first post.

Has there been anything written about using PhAB with C++?

At this point, in order to make progress, I’ve given up and done my dialog as a standalone written in straight C. I’ll just invoke it from a menu entry with minimal linkage, but it seems like a cheap solution.

Randy C.

As I suggested you need to declare your function as static within your header.

I got an example working now, but I needed to remove the entries with a :: from proto.h and to use the class-header as global header instead.

However your compiler errors should result from not having your methods declared to be static.

I know that cdm coded in C++ with PhAB … but I don’t think he was using C++ the same way that you are … There is however, a C++ SDK for QNX that you may want to look into … who knows that could be helpful ;-)

Thanks to JLV and Smeeagain for the info and the suggestion on the SDK. I’ll look into that.

Randy C.


I got an example working now, but I needed to remove the entries with a :: from proto.h and to use the class-header as global header instead.


can you post some example code here. I also encounter this problem .
in proto.h , void A::b(); are all errors . A.h ,A.cpp. Thanks

I’m not at my qnx-box for another 3 weeks, but then I’ll have a look.

SmeeAgain : ok ,Thanks a lot. and I have learned about indHfiles and indSfiles: it can contain non-phAB header files and source files. but in my src,I didn’t find these two files . just have abLfiles,abWfiles,indLfiles. my qnx is 6.3.0. you can look into it in your spare time.