Commit af1f1db9 authored by Gábor Szalai's avatar Gábor Szalai
Browse files

Update GCC version check

At the beginning the GCC (and clang) used the versioning scheme:
<major>.<minor>.<patch>

The <patch> part is ignored by the version check as the patch releases are
compatible.

Both the GCC and the Clang dropped the minor releases at the release of GCC5 & Clang5
They garantee the API & ABI compatibility within a major version, so only the
major version should be taken account.

Change-Id: I73447b7f994b0b9eb5c536a49d4fe537bbd30969
parent 9252a900
......@@ -91,10 +91,18 @@
#endif
#ifdef __clang__
#define CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100)
#if __clang_major__ > 4
#define CLANG_VERSION (__clang_major__ * 10000 )
#else
#define CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100)
#endif
#define COMPILER_VERSION_STRING " Clang: (GNU) " STR(__clang_major__) "." STR(__clang_minor__) "." STR(__clang_patchlevel__)
#else
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
#if __GNUC__ > 4
#define GCC_VERSION (__GNUC__ * 10000 )
#else
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
#endif
#define COMPILER_VERSION_STRING " GCC: (GNU) " STR(__GNUC__) "." STR(__GNUC_MINOR__) GCC_PATCHLEVEL_STRING
#endif
......
......@@ -72,9 +72,10 @@ int main(void)
"#if GCC_VERSION != %d\n"
#endif
"#error The version of " COMPILER_NAME_STRING " does not match the expected version (" COMPILER_NAME_STRING " %d.%d.%d)\n"
"#endif\n", compiler_major * 10000 + compiler_minor * 100,
"#endif\n", compiler_major>4?compiler_major * 10000:compiler_major * 10000 + compiler_minor * 100,
/* Note that we don't use compiler_patchlevel when checking.
* This assumes that code is portable between GCC a.b.x and a.b.y */
* This assumes that code is portable between GCC a.b.x and a.b.y
* The GCC & Clang changed the versioning scheme and both dropped the minor versions */
compiler_major, compiler_minor, compiler_patchlevel);
#elif defined(__SUNPRO_C)
printf("\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment