utils/: Split compiler-version macros into a separate header.
[mLib] / utils / compiler.h
1 /* -*-c-*-
2 *
3 * Macros for determining the compiler version
4 *
5 * (c) 2018 Straylight/Edgeware
6 */
7
8 /*----- Licensing notice --------------------------------------------------*
9 *
10 * This file is part of the mLib utilities library.
11 *
12 * mLib is free software: you can redistribute it and/or modify it under
13 * the terms of the GNU Library General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
16 *
17 * mLib is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 * License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib. If not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 * USA.
26 */
27
28 #ifndef MLIB_COMPILER_H
29 #define MLIB_COMPILER_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /*----- Macros ------------------------------------------------------------*/
36
37 #if defined(__GNUC__)
38 # define GCC_VERSION_P(maj, min) \
39 (__GNUC__ > (maj) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min)))
40 #else
41 # define GCC_VERSION_P(maj, min) 0
42 #endif
43
44 #ifdef __clang__
45 # define CLANG_VERSION_P(maj, min) \
46 (__clang_major__ > (maj) || (__clang_major__ == (maj) && \
47 __clang_minor__ >= (min)))
48 #else
49 # define CLANG_VERSION_P(maj, min) 0
50 #endif
51
52 /*----- That's all, folks -------------------------------------------------*/
53
54 #ifdef __cplusplus
55 }
56 #endif
57
58 #endif