1 /******************************************************************************
2 * Copyright (c) 2000-2016 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
13 ******************************************************************************/
14 /* Write a header that checks the expected version of the compiler.
15 * gccversion.c is a bit of a misnomer (also handles the Sun compiler),
16 * but it's shorter than compiler_version.c */
23 /* clang defines __GNUC__ but also has its own version numbers */
27 compiler_major
= __clang_major__
,
28 compiler_minor
= __clang_minor__
,
29 compiler_patchlevel
= __clang_patchlevel__
;
30 #define COMPILER_NAME_STRING "clang"
34 #define COMPILER_NAME_STRING "GCC"
35 unsigned int compiler_major
= __GNUC__
, compiler_minor
= __GNUC_MINOR__
;
36 # ifdef __GNUC_PATCHLEVEL__
37 unsigned int compiler_patchlevel
= __GNUC_PATCHLEVEL__
;
39 unsigned int compiler_patchlevel
= 0; /* GCC below 3.0 */
42 #endif /* __clang__ */
44 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
45 /* Just in case it's compiled with the C++ compiler */
46 # if !defined(__SUNPRO_C)
47 # define __SUNPRO_C __SUNPRO_CC
49 unsigned int compiler_major
= (__SUNPRO_C
& 0xF00) >> 8;
50 unsigned int compiler_minor
= (__SUNPRO_C
& 0x0F0) >> 4;
51 unsigned int compiler_patchlevel
= (__SUNPRO_C
& 0x00F);
54 /* unknown compiler */
55 unsigned int compiler_major
= 0, compiler_minor
= 0, compiler_patchlevel
= 0;
61 "/* Check if the compiler matches the one used to build the runtime */\n"
62 "#ifndef MAKEDEPEND_RUN\n\n");
63 /* Do not check compiler version when makedepend is being run.
64 * Old Solaris makedepend cannot compute GCC_VERSION. */
68 "#if CLANG_VERSION != %d\n"
70 "#if GCC_VERSION != %d\n"
72 "#error The version of " COMPILER_NAME_STRING
" does not match the expected version (" COMPILER_NAME_STRING
" %d.%d.%d)\n"
73 "#endif\n", compiler_major
* 10000 + compiler_minor
* 100,
74 /* Note that we don't use compiler_patchlevel when checking.
75 * This assumes that code is portable between GCC a.b.x and a.b.y */
76 compiler_major
, compiler_minor
, compiler_patchlevel
);
77 #elif defined(__SUNPRO_C)
79 "#if __SUNPRO_CC != 0x%X\n"
80 "#error The version of the Sun compiler does not match the expected version.\n"
82 compiler_major
* 0x100 + compiler_minor
* 0x10 + compiler_patchlevel
);
This page took 0.033165 seconds and 5 git commands to generate.