Fl::fatal and Fl::error trying to override

12 views
Skip to first unread message

George Reeke

unread,
Jul 31, 2022, 5:03:02 PM7/31/22
to fltk.general

I am at fltk 1.3.5 but also trying 1.3.8
Doc says I can provide my own versions of Fl::error() and Fl::fatal() to override the default actions (basically exit).  I am providing this code in my routine, compiling with gcc, and I get an error message "no 'void Fl::error(const char*, ...)' member function declared in class 'Fl'.
My code is this:
void Fl::error(const char *fmt, ...) __attribute__((noreturn));
void Fl::error(const char *fmt, ...) { <some code> }
What do I have to do to replace the default functions with my functions?

Ian MacArthur

unread,
Jul 31, 2022, 5:20:01 PM7/31/22
to Fltk General
Umm... I don’t think that’s they way it works.
Rather, you just make up your own function (of the appropriate signature, of course) and then assign that to Fl::error which is basically just a pointer to whatever the current error function is.

So something like (I’m freestyling this so it may not be literally correct...!)


static void my_error (const char *fmt, ...)
{
blah garages blah etc;
return;
}



Fl::error = my_error;


etc...


Well, something like that, anyway!


George Reeke

unread,
Aug 2, 2022, 1:20:38 PM8/2/22
to fltk.general
Thanks, doing it the way you suggest compiles OK once I found out how to pass the va_list to an inner routine.  I can't report on testing yet until I fix a few other things.

Ian MacArthur

unread,
Aug 3, 2022, 11:15:36 AM8/3/22
to fltk.general
On Tuesday, 2 August 2022 at 18:20:38 UTC+1 re...@rockefeller.edu wrote:
Thanks, doing it the way you suggest compiles OK once I found out how to pass the va_list to an inner routine.  I can't report on testing yet until I fix a few other things.


Sure - handling the varargs lists is not always intuitive... I can understand that being problematic!
Which, incidentally, now draws my attention back to me "example" where I appear to have written...

    blah garages blah etc;

Which *was* meant to say:

    blah var_args blah etc;

Except... autocorrect...
 
Reply all
Reply to author
Forward
0 new messages