Flipper Zero Firmware
Loading...
Searching...
No Matches
compiler.h
1#pragma once
2
3#ifndef __PACKED_STRUCT
4#define __PACKED_STRUCT PACKED(struct)
5#endif
6
7#ifndef __PACKED_UNION
8#define __PACKED_UNION PACKED(union)
9#endif
10
14#if defined(__ICCARM__) || defined(__IAR_SYSTEMS_ASM__)
15
16#ifndef __WEAK
17#define __WEAK __weak
18#endif
19
20#define QUOTE_(a) #a
21
28#define PACKED(decl) __packed decl
29
35#define SECTION(name) _Pragma(QUOTE_(location = name))
36
42#define ALIGN_DEF(v) _Pragma(QUOTE_(data_alignment = v))
43
50#define NO_INIT(var) __no_init var
51
55#else
56#ifdef __GNUC__
57
58#ifndef __WEAK
59#define __WEAK __attribute__((weak))
60#endif
61
68#define PACKED(decl) decl __attribute__((packed))
69
75#define SECTION(name) __attribute__((section(name)))
76
82#define ALIGN_DEF(N) __attribute__((aligned(N)))
83
90#define NO_INIT(var) var __attribute__((section(".noinit")))
91
95#else
96#ifdef __CC_ARM
97
98#ifndef __WEAK
99#define __WEAK __weak
100#endif
101
108#define PACKED(decl) decl __attribute__((packed))
109
115#define SECTION(name) __attribute__((section(name)))
116
122#define ALIGN_DEF(N) __attribute__((aligned(N)))
123
130#define NO_INIT(var) var __attribute__((section("NoInit")))
131
132#else
133
134#error Neither ICCARM, CC ARM nor GNUC C detected. Define your macros.
135
136#endif
137#endif
138#endif