Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
modules.h
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2014 Freie Universität Berlin
3
* SPDX-FileCopyrightText: 2017 HAW-Hamburg
4
* SPDX-License-Identifier: LGPL-2.1-only
5
*/
6
7
#pragma once
8
19
20
#ifdef __cplusplus
21
extern
"C"
{
22
#endif
23
56
#define IS_ACTIVE(macro) __is_active(macro)
57
67
#define IS_USED(module) IS_ACTIVE(module)
68
72
/* Here a prefix "__PREFIX_WHEN_" is added to the macro. So if it was a 1 we
73
* have "__PREFIX_WHEN_1", and if it was not defined we have "__PREFIX_WHEN_".
74
*/
75
#define __is_active(val) ___is_active(__PREFIX_WHEN_##val)
76
77
/* With this placeholder we turn the original value into two arguments when the
78
* original value was defined as 1 (note the comma).
79
*/
80
#define __PREFIX_WHEN_1 0,
81
82
/* Here we add two extra arguments, that way the next macro can accept varargs.
83
*
84
* If the original macro was defined as 1, this will have three arguments
85
* (__take_second_arg(0, 1, 0, 0)), otherwise it will have two
86
* (__take_second_arg(__PREFIX_WHEN_ 1, 0, 0)). The third zero is there just to
87
* be compliant with C99, which states that when a function-like macro ends
88
* with ellipsis (...) it should be called with at least one argument for the
89
* variable list.
90
*/
91
#define ___is_active(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0, 0)
92
93
/* Finally, we just always take the second argument, which will be either 1
94
* (when three arguments are passed, i.e. macro was defined as 1) or 0 (when
95
* only two arguments are passed).
96
*/
97
#define __take_second_arg(__ignored, val, ...) val
101
102
#ifdef __cplusplus
103
}
104
#endif
105
Generated on Sun Nov 23 2025 23:27:56 by
1.13.2