This type of code is not at all scalable (by platform). You can see
this in our old (1.3) code that has exactly that, with the (above
missing) #else case. It was usually something like:
which *implied* that the #else case is Unix/Linux/X11. This also
precluded (basically) using X11 on macOS (which is definitely
possible). Whenever you add another device/platform/driver/backend
(call it as you like) you need to add yet another #elif case at
*uncountable* places. That's the nightmare we got rid of by moving
to the "driver" structure.
This driver structure is unlimited extensible by adding "just
another class" with selected virtual methods that need to be
overridden (sharing the code of not overridden methods). This is the
ideal case. You can see it in the drawing code of the Wayland
graphics driver which reuses existing Cairo driver code.
In practice, I admit, this is not as easy as it sounds. It tends to
"copy and paste" code from one driver to another one, fix the "few
statements" that need to be replaced, and then you end up with lots
of duplicated code that needs to be maintained (mainly in the system
specific parts). That's bad and not intended. The "correct" way
needs a finer granularity of functions (virtual methods) and a good
design. This is harder to achieve but possible (and that's why I
asked Manolo about the current status of his edits and his plans for
completion).
Example: We have three totally different ways to implement timer
related code: Unix/Linux (Posix), Windows, and macOS. This led to
incompatibilities (macOS) and lack of accuracy (Windows). I don't
want to write about more details here, but I believe that a better
implementation would be doable in platform-agnostic code with only
minor system specific functions (here: virtual driver methods).
Copying the Linux/Unix/Posix code to "Wayland drivers" (which has
been done during the development) is NOT the final solution
(hopefully). That's only one example...
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'.