aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/global.h
blob: c8bc2c03f00f1945089a09fd092906d8ae034bc4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
#pragma once

//! Defines a global variable that is initialized on its first access.
/*!
 *  In contrast to a usual variable with static storage duration, this one
 *  is not susceptible to initialization order fisco issues.
 */
#define YT_DEFINE_GLOBAL(type, name, ...) \
    inline type& name() \
    { \
        static type result{__VA_ARGS__}; \
        return result;  \
    }