If your main executable uses /MD (multithreaded DLL runtime) and your DLL uses /MT (static runtime), you risk heap corruption. The new xplatcpp_windows_dll function now checks and warns if CMAKE_MSVC_RUNTIME_LIBRARY mismatches the target.
Fix: Set CMAKE_MSVC_RUNTIME_LIBRARY consistently across all projects.
The biggest headache—exporting symbols—has been eliminated. The new version introduces a XPLATCPP_PUBLIC macro that works flawlessly across MSVC, Clang, and GCC.
Old way (manual):
#ifdef _WIN32 #ifdef MYLIB_EXPORTS #define MYLIB_API __declspec(dllexport) #else #define MYLIB_API __declspec(dllimport) #endif #else #define MYLIB_API __attribute__((visibility("default"))) #endif
class MYLIB_API MyClass ... ;
New way with updated xplatcppwindowsdll: xplatcppwindowsdll updated
#include <xplatcpp/api.h>
class XPLATCPP_PUBLIC MyClass ... ;
The updated module automatically generates a .def file for MSVC, ensuring that even C++ mangled names are correctly exported without needing extern "C" wrappers. If your main executable uses /MD (multithreaded DLL
The /DELAYLOAD linker flag on Windows allows a DLL to be loaded only when its first function is called. An updater can replace the on-disk DLL during a quiescent period, and the next function call will load the new version. However, if the old version is still resident in memory, FreeLibrary must be called first—which is tricky if any threads are executing code inside it. Hot patching (rewriting function prologues to jump to new code) is possible but extremely fragile and not cross-platform.
Exceptions are not allowed to cross DLL boundaries (undefined behaviour).
All public API functions now return std::error_code or use a last‑error buffer:
PLATFORM_API int xplat_do_work(const char* input, char* error_out, size_t error_size);
Assuming you vendor the toolkit via Git submodule: The updated module automatically generates a
cd third_party/xplatcppwindowsdll
git checkout v3.0.0
cd ../..
git add third_party/xplatcppwindowsdll
If you use vcpkg or Conan, update your manifest:
// vcpkg.json
"dependencies": [
"xplatcppwindowsdll", // version >=3.0.0
]