-
Notifications
You must be signed in to change notification settings - Fork 3
/
compat.h
41 lines (36 loc) · 1.05 KB
/
compat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once
// This header provides macros for compatibility of certain features across
// multiple compilers.
// Attribute weak
#ifdef __GNUC__
#define A_WEAK __attribute__((weak))
#endif
// Attribute unused
#ifdef __GNUC__
#define A_UNUSED __attribute__((unused))
#else
#define A_UNUSED
#endif
// Static assert
#if __STDC_VERSION__ >= 201112L
#include <assert.h>
#else
#define static_assert(...)
#endif
// AVR program space macros
// Since AVR has separate address spaces for program and data, it needs
// different functions to access these spaces. Constant data is better stored
// in the program address space, to avoid wasting precious RAM.
// Usually a no-op on platforms with a single linear address space.
#ifdef __AVR__
#include <avr/pgmspace.h>
#else
#define PROGMEM
#define PSTR(...) __VA_ARGS__
#define pgm_read_ptr(x) (*x)
#define memcmp_P(...) memcmp(__VA_ARGS__)
#define memcpy_P(...) memcpy(__VA_ARGS__)
#define strlen_P(...) strlen(__VA_ARGS__)
#define vsnprintf_P(...) vsnprintf(__VA_ARGS__)
#endif