log: make once_flag constinit

This ensures we'll error out at compile time rather than encounter a
static initialisation ordering error.
This commit is contained in:
Danny Robson 2020-08-03 11:48:48 +10:00
parent f178159fba
commit 8bfb1e3d92

View File

@ -45,10 +45,8 @@ cruft::log::needs_break (level_t level)
///////////////////////////////////////////////////////////////////////////////
// mingw#xxx: MinGW doesn't have once_flag so we just use an atomic bool.
// Pray that multiple threads don't run into an issue here.
static std::once_flag s_sink_init;
static std::unique_ptr<cruft::log::sink::base> s_default_sink;
static constinit std::once_flag s_sink_init;
static constinit std::unique_ptr<cruft::log::sink::base> s_default_sink;
//-----------------------------------------------------------------------------