MCU-Common
Modules useful for embedded (MCU) programming
macros.h
Go to the documentation of this file.
1 /*
2  * This file is part of MCU-Common.
3  *
4  * Copyright (C) 2017 Adam Heinrich <adam@adamh.cz>
5  *
6  * MCU-Common is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * MCU-Common is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MCU-Common. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * As a special exception, the copyright holders of this library give
20  * you permission to link this library with independent modules to
21  * produce an executable, regardless of the license terms of these
22  * independent modules, and to copy and distribute the resulting
23  * executable under terms of your choice, provided that you also meet,
24  * for each linked independent module, the terms and conditions of the
25  * license of that module. An independent module is a module which is
26  * not derived from or based on this library. If you modify this
27  * library, you may extend this exception to your version of the
28  * library, but you are not obligated to do so. If you do not wish to
29  * do so, delete this exception statement from your version.
30  */
31 
32 #ifndef MCU_COMMON_MACROS_H
33 #define MCU_COMMON_MACROS_H
34 
40 #define VA_ARGC_IMPL(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, \
41  a14, a15, a16, n, ...) n
42 
46 #define VA_ARGC(...) VA_ARGC_IMPL(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, \
47  9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
48 
50 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x)))
51 
54 #endif /* MCU_COMMON_MACROS_H */