View topic - how to use exception and class in phab project , thanks!

how to use exception and class in phab project , thanks!

Read-only archive of qnx.gui (Creating graphical applications within a GUI environment, such as Photon or PhAB) at inn.qnx.com

how to use exception and class in phab project , thanks!

Postby dxwang » Thu Jun 01, 2006 3:25 am

In IDE, I have created a phab project , and I have found that in src folder there are all c files . but now I have two files, one is *.h, the other is *.cpp.
In *.h, there is a header include file #include <exception>. and have a class I defined.

when I add these two files to SRC folder , there are some errors about exception . and In proto.h some errors about the declaration of the function of class .such as int A::b(), it can't understand ::, what shoud I do ?


In my opinion , maybe because the c Project can't deal with the exception . how I can solve it . thanks . maybe I can add some configuration. but I don't know how to do it ,

can someone give me some advice . Thanks a lot .

can I crate the phab C++ project ?
(notice : in other c++ project ,these two files can work very well)
dxwang
Senior Member
 
Posts: 129
Joined: Mon Sep 27, 2004 1:39 pm

RE: how to use exception and class in phab project , thanks!

Postby alisha » Mon Jun 05, 2006 3:19 am

Phab support C.if you want to use class.you may not use phab,and write API directly
alisha
Active Member
 
Posts: 19
Joined: Wed May 17, 2006 3:58 am

Re: how to use exception and class in phab project , thanks!

Postby JohnMcClurkin » Mon Jun 05, 2006 12:10 pm

alisha wrote:
Phab support C.if you want to use class.you may not use phab,and write
API directly

Phab does support c++. You need to specify file names with a .C, .cc, or

..cpp extension when defining your callbacks. When Phab sees that
callback functions are in files ending with .C, .cc, or .cpp, it
generates the necessary support for C++. Note well: All callback
functions must be static and public. The this pointer needs to be
attached to the module (using Pt_ARG_POINTER) so that the static
callback function can call the appropriate instance function. Do not
generate proto.h.
JohnMcClurkin
 

Re: how to use exception and class in phab project , thanks!

Postby bilcar » Mon Jun 05, 2006 2:56 pm

I do this all the time. You can write C cover functions that can be called
by C++ code.

"alisha" <huix_2005@yahoo.com-dot-cn.no-spam.invalid> wrote in message
news:e60a7n$b5g$2@inn.qnx.com...
Phab support C.if you want to use class.you may not use phab,and write
API directly
bilcar
Senior Member
 
Posts: 573
Joined: Wed Feb 04, 2004 5:50 pm
Location: Crete, IL

RE: Re: how to use exception and class in phab project , tha

Postby dxwang » Tue Jun 06, 2006 8:45 am

to JohnMcClurkin: my cpp file with class is not my callbacks. I have wrote it in editor. now the question is : In other callbacks, I want use this class in my cpp file.
to bilcar and alisa : if I use the API directly. what's the sentence for compile. cc or ohers ? I want to support the class and exception . please write for me in detail .
Thanks !
dxwang
Senior Member
 
Posts: 129
Joined: Mon Sep 27, 2004 1:39 pm

Re: how to use exception and class in phab project , tha

Postby JohnMcClurkin » Tue Jun 06, 2006 3:51 pm

dxwang wrote:
to JohnMcClurkin: my cpp file with class is not my callbacks. I have
wrote it in editor. now the question is : In other callbacks, I
want use this class in my cpp file.
PhAB automatically generates code for C++ if it detects C++ files.

AFAIK, to make PhAB detect C++ files, specify that the callback
functions be in filenames with a .C, .cc, or .cpp suffix. The callbacks
themselves do not need to be class member functions, they just have to
be in files with C++ type suffixes.

to bilcar and alisa : if I use the API directly. what's the sentence
for compile. cc or ohers ? I want to support the class and
exception . please write for me in detail .
Thanks !
JohnMcClurkin
 

Re: how to use exception and class in phab project , tha

Postby oklapek » Fri Jun 09, 2006 10:00 am

JohnMcClurkin wrote:
dxwang wrote:

to JohnMcClurkin: my cpp file with class is not my callbacks. I have
wrote it in editor. now the question is : In other callbacks, I
want use this class in my cpp file.

PhAB automatically generates code for C++ if it detects C++ files.
AFAIK, to make PhAB detect C++ files, specify that the callback
functions be in filenames with a .C, .cc, or .cpp suffix. The callbacks
themselves do not need to be class member functions, they just have to
be in files with C++ type suffixes.

to bilcar and alisa : if I use the API directly. what's the sentence
for compile. cc or ohers ? I want to support the class and
exception . please write for me in detail .
Thanks !


I made it this way: I have rename my A.cpp file (where I have no
callbacks) to A.cxx. In this case Phab will not insert c++ functions
from my cxx file to proto.h. Than in common.mk file I have insert line
EXTRA_SUFFIXES=cxx (I don't know if IDE automaticaly support this suffix).

Regards
Marian.
oklapek
Active Member
 
Posts: 21
Joined: Thu May 06, 2004 11:16 am

RE: Re: how to use exception and class in phab project , tha

Postby dxwang » Fri Jun 09, 2006 12:53 pm

Thanks ,everyone!
I have solved it .
dxwang
Senior Member
 
Posts: 129
Joined: Mon Sep 27, 2004 1:39 pm


Return to qnx.gui

Who is online

Users browsing this forum: No registered users and 1 guest