KiCad PCB EDA Suite
Loading...
Searching...
No Matches
macros.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 Ian McInerney <[email protected]>
5 * Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
6 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
26
27#ifndef MACROS_H
28#define MACROS_H
29
30#include <wx/string.h>
31
32#if defined( __has_attribute )
33 #define KI_HAS_ATTRIBUTE( x ) __has_attribute( x )
34#else
35 #define KI_HAS_ATTRIBUTE( x ) 0
36#endif
37
38// Based on the declaration inside the LLVM source code
39#if defined( __cplusplus ) && defined( __has_cpp_attribute )
40 #define KI_HAS_CPP_ATTRIBUTE( x ) __has_cpp_attribute( x )
41#else
42 #define KI_HAS_CPP_ATTRIBUTE( x ) 0
43#endif
44
61#if __cplusplus >= 201703L
62 // C++ 17 includes this macro on all compilers
63 #define KI_FALLTHROUGH [[fallthrough]]
64
65#elif KI_HAS_CPP_ATTRIBUTE( clang::fallthrough )
66 // Clang provides this attribute to silence the "-Wimplicit-fallthrough" warning
67 #define KI_FALLTHROUGH [[clang::fallthrough]]
68
69#elif KI_HAS_CPP_ATTRIBUTE( gnu::fallthrough )
70 // GNU-specific C++ attribute to silencing the warning
71 #define KI_FALLTHROUGH [[gnu::fallthrough]]
72
73#elif defined( __GNUC__ ) && __GNUC__ >= 7
74 // GCC 7+ includes the "-Wimplicit-fallthrough" warning, and this attribute to silence it
75 #define KI_FALLTHROUGH __attribute__ ((fallthrough))
76
77#else
78 // In every other case, don't do anything
79 #define KI_FALLTHROUGH ( ( void ) 0 )
80
81#endif
82
89#define TO_STR2(x) #x
90#define TO_STR(x) TO_STR2(x)
91
92#define UNIMPLEMENTED_FOR( type ) \
93 wxFAIL_MSG( wxString::Format( wxT( "%s: unimplemented for %s" ), __FUNCTION__, type ) )
94
95#endif // MACROS_H