Problem with print# under FLTK? [SOLVED]

General FreeBASIC programming questions.
Post Reply
jevans4949
Posts: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Problem with print# under FLTK? [SOLVED]

Post by jevans4949 »

Writing a file analyser program under FLTK.

To make life simpler (I thought), I decided to send the output to a Freebasic file, using Open ... As #2, Print #2, Close #2 in a callback routine run on a button push.

It all works OK, and produces the right output, until I close the FLTK window. when a segmentation error occurs. I'm wondering if this is due to FB trying to clean up the print file, using information which disappeared with the FLTK callback routine?

Could it be because a used a string from a FLTK widget, which FLTK would have cleaned up, directly in the Open Statement?

Anybody know the answer?
Last edited by jevans4949 on Apr 17, 2017 18:03, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Problem with print# under FLTK?

Post by D.J.Peters »

Compile your code with fbc -exx yourprog.bas and run it from a console window

If you are a lucky boy you will get the line number of the crash

If you one of this unlucky boys :-)

Compile with fbc -g yourprog.bas and execute it with GDB.

On Linux type: gdb yourprog

On Windows replace XXX with your drive and FreeBASIC path e.g. d:\FreeBASIC
32-bit type XXX\bin\win32\gdb.exe yourprog.exe
64-bit type XXX\bin\win64\gdb.exe yourprog.exe

if GDB has loaded your program type r to run it

Lucky boy or not post the code around the line of crash.

Without the code no once can help to solve your problem.

Joshy
jevans4949
Posts: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Re: Problem with print# under FLTK?

Post by jevans4949 »

@D.J.Peters: Thanks to your post in the Libraries board concerning the necessity of callback functions needing to be defined as cdecl, I amended my program, and the problem has gone away.

Many thanks.
Post Reply