Merge "implemented decmatch (artf724241)"
[deliverable/titan.core.git] / core / gccversion.c
CommitLineData
d44e3c4f 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
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Beres, Szabolcs
11 * Raduly, Csaba
12 *
13 ******************************************************************************/
970ed795
EL
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 */
17
18#include <stdio.h>
19
20
21#if defined(__GNUC__)
22
23/* clang defines __GNUC__ but also has its own version numbers */
24#ifdef __clang__
25
26unsigned int
27compiler_major = __clang_major__,
28compiler_minor = __clang_minor__,
29compiler_patchlevel = __clang_patchlevel__;
30#define COMPILER_NAME_STRING "clang"
31
32#else
33
34#define COMPILER_NAME_STRING "GCC"
35unsigned int compiler_major = __GNUC__, compiler_minor = __GNUC_MINOR__;
36# ifdef __GNUC_PATCHLEVEL__
37unsigned int compiler_patchlevel = __GNUC_PATCHLEVEL__;
38# else
39unsigned int compiler_patchlevel = 0; /* GCC below 3.0 */
40# endif
41
42#endif /* __clang__ */
43
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
48# endif
49unsigned int compiler_major = (__SUNPRO_C & 0xF00) >> 8;
50unsigned int compiler_minor = (__SUNPRO_C & 0x0F0) >> 4;
51unsigned int compiler_patchlevel = (__SUNPRO_C & 0x00F);
52
53#else
54/* unknown compiler */
55unsigned int compiler_major = 0, compiler_minor = 0, compiler_patchlevel = 0;
56#endif
57
58int main(void)
59{
60 puts(
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. */
65#if defined(__GNUC__)
66 printf("\n"
67#ifdef __clang__
68 "#if CLANG_VERSION != %d\n"
69#else
70 "#if GCC_VERSION != %d\n"
71#endif
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)
78 printf("\n"
79 "#if __SUNPRO_CC != 0x%X\n"
80 "#error The version of the Sun compiler does not match the expected version.\n"
81 "#endif\n",
82 compiler_major * 0x100 + compiler_minor * 0x10 + compiler_patchlevel);
83#endif
84
85 puts("\n#endif\n");
86
87 return 0;
88}
This page took 0.029074 seconds and 5 git commands to generate.