Re: [fltk/fltk] [fltk 1.4.x/Linux] application invoking native chooser crashes under linux if if fltk built with --enable-localpng (#232)
Albrecht Schlosser
May 25, 2021
I figure the bundled code's function names have to all be changed, ...
If I read this correctly, we'd have to change the source code of the bundled libs, something I'd really want to avoid. Adding a namespace would help, but that needs C++ whereas the libs are all pure C code. I tried to compile the libs with a C++ compiler but that failed for several reasons.
As you can see (almost) the entire header Fl_Adjuster.H (I arbitrarily picked one) is surrounded by namespace FL_ADJ {...} which could in practice be in a separate file that includes the original source file. This way the original source would not need to be changed.
The trailing using namespace FL_ADJ; would normally be expected in the user (consumer) source code but is in the header file for simplicity.
With this simple proof of concept we have changed the entire class Fl_Adjuster to class FL_ADJ::Fl_Adjuster, i.e. we put it into a namespace.
With this simple change the entire FLTK lib and test files can be built.
That's how I would like to deal with the bundled libs.
User code would then only have to include the appropriate header file and get the correct linkage.
That's only a proof of concept, details need to be worked out. The problem with the bundled libs is that we really need to change the "names" which could ideally be done with such a namespace trick without editing the source code, but unfortunately I couldn't find a similar way to do it for zlib. Still thinking about a good way, but for today I had to give up.
FYI: The reason why I absolutely don't want to "edit" the source code of the bundled libs is that it would make the maintenance (upgrading) really hard. And I'm the one who did this in the past, I know what I'm talking about. It's pretty straightforward now (with a little diff magic) but I'm afraid it would be much harder if we had to edit the source code.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.