HeaderPane
Main

Dark Mode Support

Share Link
Print

SFTDARKMODE_IMPLEMENTATION

SftDarkMode.h is a single-header library in the stb-style: the header always exposes the function declarations, but the implementation is compiled only when SFTDARKMODE_IMPLEMENTATION is defined before the include.

// In one .c / .cpp file (e.g. DarkMode.cpp):
#define SFTDARKMODE_IMPLEMENTATION
#include "SftDarkMode.h"

// Everywhere else that needs the declarations:
#include "SftDarkMode.h"

Define SFTDARKMODE_IMPLEMENTATION in exactly one source file per executable - typically a small dedicated translation unit such as DarkMode.cpp. The implementation defines the SftDarkMode_* functions; without the define, the linker fails with unresolved external symbols when the application calls SftDarkMode_Init or any other helper.

Defining the macro in more than one source file produces multiple-definition linker errors for the same set of functions. Defining it in zero source files leaves the helper undefined.

The pattern lets SftDarkMode.h ship as a single header that drops into any project without requiring a separate .c / .cpp source addition - the application creates its own implementation file when (and only when) it wants the dark-mode helper compiled in.

MFC note: the dedicated implementation file is the natural place to put any application-level dark-mode setup. The MFC sample applications include a minimal DarkMode.cpp that contains nothing but the #define + #include pair.

See Also SftDarkMode | Init


Last Updated 05/09/2026 - (email)
© 2026 Softel vdm, Inc.