OpenShaderDesigner 0.0.1
Loading...
Searching...
No Matches
Startup.h
1// =====================================================================================================================
2// Copyright 2024 Medusa Slockbower
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// =====================================================================================================================
15
16#ifndef STARTUP_H
17#define STARTUP_H
18
19#ifdef __cplusplus
20#define STARTUP(f) \
21 static void f(void); \
22 struct f##_t_ { f##_t_(void) { f(); } }; inline static f##_t_ f##_; \
23 static void f(void)
24#elif defined(_MSC_VER)
25#pragma section(".CRT$XCU",read)
26 #define INITIALIZER2_(f,p) \
27 static void f(void); \
28 __declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
29 __pragma(comment(linker,"/include:" p #f "_")) \
30 static void f(void)
31 #ifdef _WIN64
32 #define STARTUP(f) INITIALIZER2_(f,"")
33 #else
34 #define STARTUP(f) INITIALIZER2_(f,"_")
35 #endif
36#else
37 #define STARTUP(f) \
38 static void f(void) __attribute__((constructor)); \
39 static void f(void)
40#endif
41
42#endif //STARTUP_H