Skip to content

June 30, 2024

☀️ Sane C++ June 2024#

SC

Welcome to the Sane C++ Libraries June 2024 update post!
The month has been spent mainly building SCExample, a small GUI example app to showcase some Libraries (mainly SC::Async / SC::Plugin / SC::FileSystemWatcher).

📄 Sane C++ Libraries Documentation
💻 Sane C++ Libraries Repository
📹 Sane Coding Youtube channel
💬 Sane Coding Discord

SCExample#

Always give a good example

SCExample is a small GUI application based on sokol_app / sokol_gfx libraries, providing window abstraction and graphics api abstraction and dear-imgui for the UI. Building this application has been mostly documented in the following YouTube videos:

First step has been putting together a pure cross platform GUI application (win/linux/macos), making sure to pause the render loop in absence of user inputs:

Second step has been integrating the GUI event loop with the SC::Async I/O library (always cross-platform).

And lastly showcasing the integration of SC::FileSystemWatcher and SC::Plugin to watch source files that are being hot-reloaded as plugins (dynamic libraries).
Also in this case the cross-platform aspect has been preserved.

This is the list of SCExample related commits:

SC::Async#

A single event loop is never enough

A small but useful addition to the SC::Async library has been the SC::AsyncEventLoopMonitor class. This class wraps most of the required machinery to integrate SC::Async event loop in an application that has a different main event loop (GUI or IO)

SC::Plugin#

Hot-Reload like there is no tomorrow

SC::Plugin library has been receiving some love, with the addition of a queryInterface-like mechanism helping to define contracts between plugins and the host application. It's possible to control linking libc / libc++, adding some custom include directories and disabling exceptions. SC::Plugin now monitors CFLAGS and LDFLAGS environment variables (if defined) of the host environment, to allow linking the correct sysroot on posix systems. Some fixes too have been needed on macOS where duplicated plugin symbols from different compiled .dylibs can wrongly increment their refcount, preventing from unloading them.

SC::FileSystemWatcher#

Make it actually usable

Using SC::FileSystemWatcher inside SC::Example has exposed some usability issues and bugs (mainly repeated notifications), that have been promptly fixed.

SC::Build#

Spaces and GUI Apps

SC::Build can now generate Xcode projects for gui applications creating app bundles on macOS for the Xcode backend. The configure phase will download required dependencies (like sokol or dear-imgui for SCExample). This is not ideal as it requires internet connection, so it will be probably be made optional in some future update. It can now build from paths with spaces (even when using the Makefile backend...) and generates Xcode projects avoiding any warning. Some of the fixes have ramifications also on the SC::Tools that bootstraps SC::Build.

Additional fixes#

Fix fix fix

And just like every month, working on SCExample has generated a number of minor fixes, API improvements / refactoring.
All of them have been proudly committed to the main branch!