macros.h
1 /*
2  * MoMEMta: a modular implementation of the Matrix Element Method
3  * Copyright (C) 2017 Universite catholique de Louvain (UCL), Belgium
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 // Compiler attributes
22 
23 // Use C++17 attributes if supported
24 #if __cplusplus >= 201703L
25 
26 #define ATTRIBUTE_DEPRECATED [[deprecated]]
27 #define ATTRIBUTE_UNUSED [[maybe_unused]]
28 
29 // Or C++14
30 #elif __cplusplus >= 201402L
31 
32 #define ATTRIBUTE_DEPRECATED [[deprecated]]
33 
34 #endif
35 
36 #if (defined(__GNUC__) || defined(__APPLE__))
37 
38 // Compiler supports GCC-style attributes
39 #ifndef ATTRIBUTE_DEPRECATED
40 #define ATTRIBUTE_DEPRECATED __attribute__((deprecated))
41 #endif
42 
43 #ifndef ATTRIBUTE_UNUSED
44 #define ATTRIBUTE_UNUSED __attribute__((unused))
45 #endif
46 
47 #else
48 
49 #ifndef ATTRIBUTE_DEPRECATED
50 #define ATTRIBUTE_DEPRECATED
51 #endif
52 
53 #ifndef ATTRIBUTE_UNUSED
54 #define ATTRIBUTE_UNUSED
55 #endif
56 
57 #endif