summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/global.h
blob: df831b50c3f2afcad7878a6aff8ad6ff7369f600 (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;  \
    }