Re: XForms: Segmentation Faults with C++

Thomas Thiel (wolfchild@home.ivm.de)
Thu, 25 Feb 1999 08:38:40

# To subscribers of the xforms list from Thomas Thiel <wolfchild@home.ivm.de> :

At 12:08 24.02.1999 -0500, you wrote:

>I write all of my XForms applications in C++. They work just fine.
How are you handling the XForm-Objects ? fl_do_forms()? Callbacks ? Could
you send me some code to compare ?

>If you gave us some more information, perhaps we could help. What
>compiler are you using ? How are you linking ? Are you calling
>fl_initialize() ? Give us a small piece of sample code, and I imagine
>the problem will be fairly obvious.
Ok, I'm using gcc V2.7.2.3 without using code optimization. I link with the
parameters -lX11 -lm -lforms, just as told in the docs.
Actually, just any XForms App I wrote in C was running without any
problems. I don't have much time at the moment, so i can't support complete
sample code, but i add my class-definitions at the end. I wrote a class
wich constructor call defines a form object. After defining it, it is
displayed by calling fl_show_form(). After that my problem starts. Its the
same if I call fl_do_forms() or if I define Callbacks for my controls:
segmentation fault.
As I can say, everything is syntactically correct... The compiler doesn't
even warn me for anything while using fl_do_forms. If I use a
callback-definition, my code lacks a typecast, but it is auto-converted
correctly.

BTW: Yes, I DID call fl_initialize().... ;)

----------------------------------------------------------------------------
-------------------------------------

My class definitions (don't laugh, I'm new to C++ ):

class IF_RobotControl_Class
{
private:

FL_FORM *RobotControl;
FL_OBJECT *Reg1,*Reg2,*Reg3,*Reg4,*Reg5,*Reg6,*DoTurn,*Result;

DoTurnCallback(FL_OBJECT *obj, long argssss);

public:

IF_RobotControl_Class();
~IF_RobotControl_Class();

};

IF_RobotControl_Class::DoTurnCallback(FL_OBJECT *obj, long argssss)
{
printf("Hi !");
};

IF_RobotControl_Class::IF_RobotControl_Class()
{

RobotControl=fl_bgn_form(FL_UP_BOX,50,550);

DoTurn=fl_add_button(FL_NORMAL_BUTTON,10,500,101,30,"Do Turn");

fl_end_form();

fl_show_form(RobotControl,FL_PLACE_MOUSE,FL_FULLBORDER,"RoboRace V.1a");
Result=fl_do_forms();

// fl_set_object_callback(DoTurn,&DoTurnCallback,0);

};

IF_RobotControl_Class::~IF_RobotControl_Class()
{

fl_hide_form(RobotControl);

};

Hope, it helps.... :)
___

Greetz,

---> Lord Wolfchild <---
[wolfchild@home.ivm.de]
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/