Krita Source Code Documentation
Loading...
Searching...
No Matches
KisStaticInitializer.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KISSTATICINITIALIZER_H
7#define KISSTATICINITIALIZER_H
8
9#ifndef CONCAT
10#define CONCAT(a, b) CONCAT_IMPL(a, b)
11#define CONCAT_IMPL(a, b) a ## b
12#endif
13
14#define KIS_DECLARE_STATIC_INITIALIZER_IMPL(uniqueId) \
15 static void CONCAT(initializerFunc, uniqueId)(); \
16\
17 class CONCAT(InitializerStruct, uniqueId) \
18 { \
19 public: \
20 CONCAT(InitializerStruct, uniqueId)(void (*initializer)()) { \
21 initializer(); \
22 } \
23 }; \
24\
25 static CONCAT(InitializerStruct, uniqueId) CONCAT(__initializerVariable, uniqueId)(&CONCAT(initializerFunc, uniqueId)); \
26\
27 void CONCAT(initializerFunc, uniqueId)()
28
38#define KIS_DECLARE_STATIC_INITIALIZER KIS_DECLARE_STATIC_INITIALIZER_IMPL(__COUNTER__)
39
40
41#endif // KISSTATICINITIALIZER_H