From c3657504c642129865fc8cfdeacb98ef2da8d830 Mon Sep 17 00:00:00 2001 From: babenko Date: Sat, 14 Dec 2024 10:23:55 +0300 Subject: Introduce (any use) YT_STATIC_INITIALIZER commit_hash:7d3055f901a21e63f7860f443252a86e9895fd08 --- library/cpp/yt/misc/static_initializer.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 library/cpp/yt/misc/static_initializer.h (limited to 'library') diff --git a/library/cpp/yt/misc/static_initializer.h b/library/cpp/yt/misc/static_initializer.h new file mode 100644 index 00000000000..ebaa35a1a24 --- /dev/null +++ b/library/cpp/yt/misc/static_initializer.h @@ -0,0 +1,19 @@ +#pragma once + +#include "preprocessor.h" + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +//! Static initializer will be invoked prior to entering |main|. +//! The exact order of these invocations is, of course, undefined. +#define YT_STATIC_INITIALIZER(...) \ + [[maybe_unused]] static inline const void* PP_ANONYMOUS_VARIABLE(StaticInitializer) = [] { \ + __VA_ARGS__; \ + return nullptr; \ + } () + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT -- cgit v1.3