|
126 | 126 | # error Unknown borland c++ Compiler Version
|
127 | 127 | # endif
|
128 | 128 |
|
129 |
| -// gnu c/c++ |
130 |
| -#elif defined(__GNUC__) |
131 |
| -# define TB_COMPILER_IS_GCC |
| 129 | +// gcc or clang |
| 130 | +#elif defined(__GNUC__) || defined(__clang__) |
| 131 | + |
132 | 132 | # if defined(__MINGW32__) || defined(__MINGW64__)
|
133 | 133 | # define TB_COMPILER_IS_MINGW
|
134 | 134 | # endif
|
|
142 | 142 | defined(TB_COMPILER_ON_MSYS) || defined(TB_COMPILER_ON_CYGWIN)
|
143 | 143 | # define TB_COMPILER_LIKE_UNIX
|
144 | 144 | # endif
|
145 |
| -# define TB_COMPILER_VERSION_BT(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) > ((major) * 100 + (minor))) |
146 |
| -# define TB_COMPILER_VERSION_BE(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) >= ((major) * 100 + (minor))) |
147 |
| -# define TB_COMPILER_VERSION_EQ(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) == ((major) * 100 + (minor))) |
148 |
| -# define TB_COMPILER_VERSION_LT(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) < ((major) * 100 + (minor))) |
149 |
| -# define TB_COMPILER_VERSION_LE(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) <= ((major) * 100 + (minor))) |
150 |
| -# define TB_COMPILER_STRING "gnu c/c++" |
151 |
| -# if __GNUC__ == 2 |
152 |
| -# if __GNUC_MINOR__ < 95 |
153 |
| -# define TB_COMPILER_VERSION_STRING "gnu c/c++ <2.95" |
154 |
| -# elif __GNUC_MINOR__ == 95 |
155 |
| -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 2.95" |
156 |
| -# elif __GNUC_MINOR__ == 96 |
157 |
| -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 2.96" |
158 |
| -# else |
159 |
| -# define TB_COMPILER_VERSION_STRING "gnu c/c++ > 2.96 && < 3.0" |
160 |
| -# endif |
161 |
| -# elif __GNUC__ == 3 |
162 |
| -# if __GNUC_MINOR__ == 2 |
163 |
| -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.2" |
164 |
| -# elif __GNUC_MINOR__ == 3 |
165 |
| -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.3" |
166 |
| -# elif __GNUC_MINOR__ == 4 |
167 |
| -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.4" |
168 |
| -# else |
169 |
| -# define TB_COMPILER_VERSION_STRING "gnu c/c++ > 3.4 && < 4.0" |
170 |
| -# endif |
171 |
| -# elif __GNUC__ >= 4 && defined(__GNUC_MINOR__) |
172 |
| -# define TB_COMPILER_VERSION_STRING __tb_mstrcat4__("gnu c/c++ ", __tb_mstring_ex__(__GNUC__), ".", __tb_mstring_ex__(__GNUC_MINOR__)) |
173 |
| -# else |
174 |
| -# error Unknown gnu c/c++ Compiler Version |
| 145 | + |
| 146 | +# if defined(__clang__) |
| 147 | +# define TB_COMPILER_IS_CLANG |
175 | 148 | # endif
|
176 | 149 |
|
| 150 | + // we always need to be compatible with gcc style code if the current compiler is clang |
| 151 | +# define TB_COMPILER_IS_GCC |
| 152 | + |
177 | 153 | // clang
|
178 | 154 | # if defined(__clang__)
|
179 |
| -# define TB_COMPILER_IS_CLANG |
180 | 155 | # undef TB_COMPILER_STRING
|
181 | 156 | # define TB_COMPILER_STRING "clang c/c++"
|
| 157 | +# define TB_COMPILER_VERSION_BT(major, minor) ((__clang_major__ * 100 + __clang_minor__) > ((major) * 100 + (minor))) |
| 158 | +# define TB_COMPILER_VERSION_BE(major, minor) ((__clang_major__ * 100 + __clang_minor__) >= ((major) * 100 + (minor))) |
| 159 | +# define TB_COMPILER_VERSION_EQ(major, minor) ((__clang_major__ * 100 + __clang_minor__) == ((major) * 100 + (minor))) |
| 160 | +# define TB_COMPILER_VERSION_LT(major, minor) ((__clang_major__ * 100 + __clang_minor__) < ((major) * 100 + (minor))) |
| 161 | +# define TB_COMPILER_VERSION_LE(major, minor) ((__clang_major__ * 100 + __clang_minor__) <= ((major) * 100 + (minor))) |
182 | 162 | # if defined(__VERSION__)
|
183 | 163 | # undef TB_COMPILER_VERSION_STRING
|
184 | 164 | # define TB_COMPILER_VERSION_STRING __VERSION__
|
|
204 | 184 | * pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
|
205 | 185 | */
|
206 | 186 | # pragma clang diagnostic ignored "-Wnullability-completeness"
|
| 187 | + |
| 188 | + // gcc |
| 189 | +# elif defined(__GNUC__) |
| 190 | +# define TB_COMPILER_VERSION_BT(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) > ((major) * 100 + (minor))) |
| 191 | +# define TB_COMPILER_VERSION_BE(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) >= ((major) * 100 + (minor))) |
| 192 | +# define TB_COMPILER_VERSION_EQ(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) == ((major) * 100 + (minor))) |
| 193 | +# define TB_COMPILER_VERSION_LT(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) < ((major) * 100 + (minor))) |
| 194 | +# define TB_COMPILER_VERSION_LE(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) <= ((major) * 100 + (minor))) |
| 195 | +# define TB_COMPILER_STRING "gnu c/c++" |
| 196 | +# if __GNUC__ == 2 |
| 197 | +# if __GNUC_MINOR__ < 95 |
| 198 | +# define TB_COMPILER_VERSION_STRING "gnu c/c++ <2.95" |
| 199 | +# elif __GNUC_MINOR__ == 95 |
| 200 | +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 2.95" |
| 201 | +# elif __GNUC_MINOR__ == 96 |
| 202 | +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 2.96" |
| 203 | +# else |
| 204 | +# define TB_COMPILER_VERSION_STRING "gnu c/c++ > 2.96 && < 3.0" |
| 205 | +# endif |
| 206 | +# elif __GNUC__ == 3 |
| 207 | +# if __GNUC_MINOR__ == 2 |
| 208 | +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.2" |
| 209 | +# elif __GNUC_MINOR__ == 3 |
| 210 | +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.3" |
| 211 | +# elif __GNUC_MINOR__ == 4 |
| 212 | +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.4" |
| 213 | +# else |
| 214 | +# define TB_COMPILER_VERSION_STRING "gnu c/c++ > 3.4 && < 4.0" |
| 215 | +# endif |
| 216 | +# elif __GNUC__ >= 4 && defined(__GNUC_MINOR__) |
| 217 | +# define TB_COMPILER_VERSION_STRING __tb_mstrcat4__("gnu c/c++ ", __tb_mstring_ex__(__GNUC__), ".", __tb_mstring_ex__(__GNUC_MINOR__)) |
| 218 | +# else |
| 219 | +# error Unknown gnu c/c++ Compiler Version |
| 220 | +# endif |
207 | 221 | # endif
|
208 | 222 |
|
209 | 223 | // watcom c/c++
|
|
0 commit comments