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
* Copyright (C) 2014 Freie Universität Berlin
3
* 2017 HAW-Hamburg
4
*
5
* This file is subject to the terms and conditions of the GNU Lesser
6
* General Public License v2.1. See the file LICENSE in the top level
7
* directory for more details.
8
*/
9
21
#ifndef MODULES_H
22
#define MODULES_H
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
27
60
#define IS_ACTIVE(macro) __is_active(macro)
61
71
#define IS_USED(module) IS_ACTIVE(module)
72
76
/* Here a prefix "__PREFIX_WHEN_" is added to the macro. So if it was a 1 we
77
* have "__PREFIX_WHEN_1", and if it was not defined we have "__PREFIX_WHEN_".
78
*/
79
#define __is_active(val) ___is_active(__PREFIX_WHEN_##val)
80
81
/* With this placeholder we turn the original value into two arguments when the
82
* original value was defined as 1 (note the comma).
83
*/
84
#define __PREFIX_WHEN_1 0,
85
86
/* Here we add two extra arguments, that way the next macro can accept varargs.
87
*
88
* If the original macro was defined as 1, this will have three arguments
89
* (__take_second_arg(0, 1, 0, 0)), otherwise it will have two
90
* (__take_second_arg(__PREFIX_WHEN_ 1, 0, 0)). The third zero is there just to
91
* be compliant with C99, which states that when a function-like macro ends
92
* with ellipsis (...) it should be called with at least one argument for the
93
* variable list.
94
*/
95
#define ___is_active(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0, 0)
96
97
/* Finally, we just always take the second argument, which will be either 1
98
* (when three arguments are passed, i.e. macro was defined as 1) or 0 (when
99
* only two arguments are passed).
100
*/
101
#define __take_second_arg(__ignored, val, ...) val
106
#ifdef __cplusplus
107
}
108
#endif
109
110
#endif
/* MODULES_H */
Generated on Fri Nov 15 2024 20:23:55 by
1.9.8