1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2015 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 /* Write a header that checks the expected version of the compiler.
9 * gccversion.c is a bit of a misnomer (also handles the Sun compiler),
10 * but it's shorter than compiler_version.c */
17 /* clang defines __GNUC__ but also has its own version numbers */
21 compiler_major
= __clang_major__
,
22 compiler_minor
= __clang_minor__
,
23 compiler_patchlevel
= __clang_patchlevel__
;
24 #define COMPILER_NAME_STRING "clang"
28 #define COMPILER_NAME_STRING "GCC"
29 unsigned int compiler_major
= __GNUC__
, compiler_minor
= __GNUC_MINOR__
;
30 # ifdef __GNUC_PATCHLEVEL__
31 unsigned int compiler_patchlevel
= __GNUC_PATCHLEVEL__
;
33 unsigned int compiler_patchlevel
= 0; /* GCC below 3.0 */
36 #endif /* __clang__ */
38 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
39 /* Just in case it's compiled with the C++ compiler */
40 # if !defined(__SUNPRO_C)
41 # define __SUNPRO_C __SUNPRO_CC
43 unsigned int compiler_major
= (__SUNPRO_C
& 0xF00) >> 8;
44 unsigned int compiler_minor
= (__SUNPRO_C
& 0x0F0) >> 4;
45 unsigned int compiler_patchlevel
= (__SUNPRO_C
& 0x00F);
48 /* unknown compiler */
49 unsigned int compiler_major
= 0, compiler_minor
= 0, compiler_patchlevel
= 0;
55 "/* Check if the compiler matches the one used to build the runtime */\n"
56 "#ifndef MAKEDEPEND_RUN\n\n");
57 /* Do not check compiler version when makedepend is being run.
58 * Old Solaris makedepend cannot compute GCC_VERSION. */
62 "#if CLANG_VERSION != %d\n"
64 "#if GCC_VERSION != %d\n"
66 "#error The version of " COMPILER_NAME_STRING
" does not match the expected version (" COMPILER_NAME_STRING
" %d.%d.%d)\n"
67 "#endif\n", compiler_major
* 10000 + compiler_minor
* 100,
68 /* Note that we don't use compiler_patchlevel when checking.
69 * This assumes that code is portable between GCC a.b.x and a.b.y */
70 compiler_major
, compiler_minor
, compiler_patchlevel
);
71 #elif defined(__SUNPRO_C)
73 "#if __SUNPRO_CC != 0x%X\n"
74 "#error The version of the Sun compiler does not match the expected version.\n"
76 compiler_major
* 0x100 + compiler_minor
* 0x10 + compiler_patchlevel
);
This page took 0.032361 seconds and 5 git commands to generate.