What are the 'Good FLTK coding habits'?

30 views
Skip to first unread message

Andre Steenveld

unread,
Oct 20, 2026, 6:50:46 AMOct 20
to fltk.general
Dear all,

While working with FLTK I sometimes ask myself what form to use. Or, what is the advised habit for a part of code for FLTK? In other words 'What are good habits while using FLTK?'

I have looked aroud and found some remarks here and there but not a comprehensive overview on what (and what not) to do. So far I have found only a few remarks and this way I will never get a full overview. Is it an idea to collect this in a file 'README.coding_recomendations.txt'? This is aimed at the programmer who want to use FLTK as quickly but also as efficient as possible.

- The recommended FLTK building system is CMake. Optional for v1.4.x, mandatory for v1.5.x and newer. See: README.CMake.txt

- Avoid installing multiple versions of the same minor version for system wide use (e.g.: do not install v1.4.x and v1.4.y). If multiple versions are needed build a local version and directly use the build results (without installing it.) See also: README.abi-version.txt

- All widget classes use the "Fl_" prefix with capital 'F' and lowercase 'l'.
- Constants etc. may use the "FL" prefix

- Always include the public build configuration header `#include <FL/fl_config.h>`

- Avoid the use static instances of widget classes. (Check the next point!)
  It may lead to cleanup problems and hard to debug exceptions.

- Widgets are commonly ordered into functional groups, which in turn may be grouped again, creating a hierarchy of widgets. Fill groups by automatically adding widgets that are created between an (optional) myGroup->begin() and (not optional) myGroup->end(). The group becomes the owner of a created instance and will dispose it on cleanup. Setting the current group to NULL will stop automatic hierarchies. New widgets can now be added manually using Fl_Group::add(...) and Fl_Group::insert(...)

- read https://www.fltk.org/documentation.php for more detailed information.

Kind regards,
Andre Steenveld.
Reply all
Reply to author
Forward
0 new messages