main
1
2#ifndef KC_HEADER_MACROS_MACROS_INCLUDED
3#define KC_HEADER_MACROS_MACROS_INCLUDED
4
5#define EMPTY()
6
7#define DEFER( macro ) macro EMPTY()
8#define OBSTRUCT( ... ) __VA_ARGS__ DEFER( EMPTY )()
9#define EXPAND( ... ) __VA_ARGS__
10
11#define STRING_JOIN( str1, str2 ) str1##str2
12
13#define UNIQUE_NAME( name ) EXPAND( DEFER( STRING_JOIN )( name, __LINE__ ) )
14
15#define ASSERT( expression ) \
16 typedef char UNIQUE_NAME( compile_time_assert )[( expression ) ? 1 : -1]
17
18#define STRINGIZE( str ) #str
19#define STRINGIZE_MACRO( macro ) STRINGIZE( macro )
20
21#include "../platform/info.h"
22
23#if defined(KC_COMPILER_GCC) || defined(KC_COMPILER_CLANG) || defined(KC_COMPILER_TCC)
24
25 #define PACK( definition ) definition __attribute__( ( __packed__ ) )
26 #define IN_CUSTOM_SECTION( section_name, type, ... ) type __attribute__((section(#section_name))) __VA_ARGS__
27
28#elif defined(KC_COMPILER_MSVC)
29
30 #define PACK( DECL ) \
31 __pragma( pack( push, 1 ) ) \
32 DECL \
33 __pragma( pack( pop ) )
34
35 #define IN_CUSTOM_SECTION( section_name, ... ) __declspec(allocate(#section_name)) __VA_ARGS__
36
37
38#else
39 #error Unsupported compiler.
40#endif
41
42#endif