Pyrogenesis
HEAD
Pyrogenesis, a RTS Engine
compiler.h
Go to the documentation of this file.
1
/* Copyright (c) 2025 Wildfire Games.
2
*
3
* Permission is hereby granted, free of charge, to any person obtaining
4
* a copy of this software and associated documentation files (the
5
* "Software"), to deal in the Software without restriction, including
6
* without limitation the rights to use, copy, modify, merge, publish,
7
* distribute, sublicense, and/or sell copies of the Software, and to
8
* permit persons to whom the Software is furnished to do so, subject to
9
* the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included
12
* in all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
*/
22
23
/*
24
* compiler-specific macros and fixes
25
*/
26
27
#ifndef INCLUDED_COMPILER
28
#define INCLUDED_COMPILER
29
30
// detect compiler and its version (0 if not present, otherwise
31
// major*100 + minor). note that more than one *_VERSION may be
32
// non-zero due to interoperability.
33
// .. VC
34
#ifdef _MSC_VER
35
# define MSC_VERSION _MSC_VER
36
#else
37
# define MSC_VERSION 0
38
#endif
39
// .. GCC
40
#ifdef __GNUC__
41
# define GCC_VERSION (__GNUC__*100 + __GNUC_MINOR__)
42
#else
43
# define GCC_VERSION 0
44
#endif
45
// .. Clang/LLVM (GCC-compatible)
46
// use Clang's feature checking macros to check for availability of features
47
// http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
48
#ifdef __clang__
49
# define CLANG_VERSION (__clang_major__*100 + __clang_minor__)
50
#else
51
# define CLANG_VERSION 0
52
#endif
53
54
// Clang/LLVM feature check macro compatibility
55
#ifndef __has_feature
56
# define __has_feature(x) 0
57
#endif
58
59
#ifndef __has_cpp_attribute
60
# define __has_cpp_attribute(x) 0
61
#endif
62
63
// check if compiling in pure C mode (not C++) with support for C99.
64
// (this is more convenient than testing __STDC_VERSION__ directly)
65
//
66
// note: C99 provides several useful but disjunct bits of functionality.
67
// unfortunately, most C++ compilers do not offer a complete implementation.
68
// however, many of these features are likely to be added to C++, and/or are
69
// already available as extensions. what we'll do is add a HAVE_ macro for
70
// each feature and test those instead. they are set if HAVE_C99, or also if
71
// the compiler happens to support something compatible.
72
//
73
// rationale: lying about __STDC_VERSION__ via Premake so as to enable support
74
// for some C99 functions doesn't work. Mac OS X headers would then use the
75
// restrict keyword, which is never supported by g++ (because that might
76
// end up breaking valid C++98 programs).
77
#define HAVE_C99 0
78
#ifdef __STDC_VERSION__
79
# if __STDC_VERSION__ >= 199901L
80
# undef HAVE_C99
81
# define HAVE_C99 1
82
# endif
83
#endif
84
85
// Streaming SIMD Extensions (not supported by all GCC)
86
// this only ascertains compiler support; use x86_x64::Cap to
87
// check whether the instructions are supported by the CPU.
88
#ifndef COMPILER_HAS_SSE
89
# if GCC_VERSION && defined(__SSE__)
90
# define COMPILER_HAS_SSE 1
91
# elif MSC_VERSION
92
# define COMPILER_HAS_SSE 1
93
# else
94
# define COMPILER_HAS_SSE 0
95
# endif
96
#endif
97
98
#ifndef COMPILER_HAS_SSE2
99
# if GCC_VERSION && defined(__SSE2__)
100
# define COMPILER_HAS_SSE2 1
101
# elif MSC_VERSION
102
# define COMPILER_HAS_SSE2 1
103
# else
104
# define COMPILER_HAS_SSE2 0
105
# endif
106
#endif
107
108
#endif
// #ifndef INCLUDED_COMPILER
source
lib
sysdep
compiler.h
Generated by
1.9.4