Merge pull request #10558 from iNavFlight/MrD_Correct-comments-on-OSD-symbols
[inav.git] / src / main / config / config_reset.h
blob3c7a62fcc9873387fa9d00a55ac153d444eb1c6a
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #include <string.h>
22 #ifndef __UNIQL
23 # define __UNIQL_CONCAT2(x,y) x ## y
24 # define __UNIQL_CONCAT(x,y) __UNIQL_CONCAT2(x,y)
25 # define __UNIQL(x) __UNIQL_CONCAT(x,__LINE__)
26 #endif
28 // overwrite _name with data passed as arguments. This version forces GCC to really copy data
29 // It is not possible to use multiple RESET_CONFIGs on single line (__UNIQL limitation)
30 #define RESET_CONFIG(_type, _name, ...) \
31 static const _type __UNIQL(_reset_template_) = { \
32 __VA_ARGS__ \
33 }; \
34 memcpy((_name), &__UNIQL(_reset_template_), sizeof(*(_name))); \
35 /**/
37 // overwrite _name with data passed as arguments. GCC is allowed to set structure field-by-field
38 #define RESET_CONFIG_2(_type, _name, ...) \
39 *(_name) = (_type) { \
40 __VA_ARGS__ \
41 }; \
42 /**/