~ubuntu-branches/ubuntu/feisty/soqt/feisty

« back to all changes in this revision

Viewing changes to cfg/m4/compiler_capabilities.m4

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2004-05-29 02:58:50 UTC
  • Revision ID: james.westby@ubuntu.com-20040529025850-nkh0l2b0mixwkcgh
Tags: 1.0.2-3
Build against coin-2, rather than coin-1.  Closes: #241102.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
############################################################################
 
2
# Usage:
 
3
#   SIM_AC_COMPILER_CPLUSPLUS_FATAL_ERRORS
 
4
#
 
5
# Description:
 
6
#   Check for the known causes that would make the current C++ compiler
 
7
#   unusable for building Coin or Coin-related projects.
 
8
#
 
9
#   Exits the configure script if any of them fail.
 
10
#
 
11
 
 
12
AC_DEFUN([SIM_AC_COMPILER_CPLUSPLUS_FATAL_ERRORS], [
 
13
  SIM_AC_COMPILER_INLINE_FOR
 
14
  SIM_AC_COMPILER_SWITCH_IN_VIRTUAL_DESTRUCTOR
 
15
  SIM_AC_COMPILER_CRAZY_GCC296_BUG
 
16
])
 
17
 
 
18
 
 
19
 
 
20
############################################################################
 
21
# Usage:
 
22
#   SIM_AC_COMPILER_INLINE_FOR( [ACTION-IF-OK [, ACTION-IF-FAILS ] ] )
 
23
#
 
24
# Description:
 
25
#   Check if the compiler supports for(;;){} loops inside inlined
 
26
#   constructors.
 
27
#
 
28
#   This smokes out the useless HPUX 10.20 CC compiler.
 
29
#
 
30
 
 
31
AC_DEFUN([SIM_AC_COMPILER_INLINE_FOR], [
 
32
 
 
33
AC_CACHE_CHECK(
 
34
  [if the compiler handles for() loops in inlined constructors],
 
35
  sim_cv_c_inlinefor,
 
36
  [AC_TRY_COMPILE([
 
37
class TestClass {
 
38
public:
 
39
  TestClass(int);
 
40
};
 
41
 
 
42
inline TestClass::TestClass(int) { for (int i=0; i<1; i++) i=0; }
 
43
],
 
44
                 [TestClass t(0);],
 
45
                 [sim_cv_c_inlinefor=yes],
 
46
                 [sim_cv_c_inlinefor=no])
 
47
])
 
48
 
 
49
if test x"$sim_cv_c_inlinefor" = x"yes"; then
 
50
  ifelse([$1], , :, [$1])
 
51
else
 
52
  SIM_AC_ERROR([c--inlinefor])
 
53
  $2
 
54
fi
 
55
])
 
56
 
 
57
 
 
58
############################################################################
 
59
# Usage:
 
60
#   SIM_AC_COMPILER_SWITCH_IN_VIRTUAL_DESTRUCTOR( [ACTION-IF-OK [, ACTION-IF-FAILS ] ] )
 
61
#
 
62
# Description:
 
63
#   Check if the compiler crashes on switch() statements inside virtual
 
64
#   destructors.
 
65
#
 
66
#   This smokes out a particular patch-level version of the CC compiler
 
67
#   for Sun WorkShop 6 (update 1 C++ 5.2 Patch 109508-01 2001/01/31).
 
68
#
 
69
 
 
70
AC_DEFUN([SIM_AC_COMPILER_SWITCH_IN_VIRTUAL_DESTRUCTOR], [
 
71
 
 
72
AC_CACHE_CHECK(
 
73
  [if the compiler handles switch statements in virtual destructors],
 
74
  sim_cv_c_virtualdestrswitch,
 
75
  [AC_TRY_COMPILE([
 
76
class hepp { virtual ~hepp(); };
 
77
hepp::~hepp() { switch(0) { } }
 
78
],
 
79
[],
 
80
                  [sim_cv_c_virtualdestrswitch=yes],
 
81
                  [sim_cv_c_virtualdestrswitch=no])])
 
82
 
 
83
if test x"$sim_cv_c_virtualdestrswitch" = x"yes"; then
 
84
  ifelse([$1], , :, [$1])
 
85
else
 
86
  SIM_AC_ERROR([c--vdest])
 
87
  $2
 
88
fi
 
89
])
 
90
 
 
91
 
 
92
############################################################################
 
93
# Usage:
 
94
#     SIM_AC_COMPILER_CRAZY_GCC296_BUG([ACTION-IF-OK [, ACTION-IF-FAILS ]])
 
95
#
 
96
# Description:
 
97
#   Tries to smoke out some completely fubar bug in g++ of GCC 2.96
 
98
#   (at least) when -O2 (or higher, probably) optimization on. The reason
 
99
#   we check specifically for this bug is because this compiler version
 
100
#   is pretty well spread because it was part of a Red Hat Linux release.
 
101
#
 
102
 
 
103
AC_DEFUN([SIM_AC_COMPILER_CRAZY_GCC296_BUG], [
 
104
 
 
105
AC_CACHE_CHECK(
 
106
  [if this is a version of GCC with a known nasty optimization bug],
 
107
  sim_cv_c_gcctwonightysixbug,
 
108
  [AC_TRY_RUN([
 
109
#include <stdio.h>
 
110
 
 
111
class myclass {
 
112
public:
 
113
  float value;
 
114
  float & ref();
 
115
};
 
116
 
 
117
myclass
 
118
hepp(const float v0, const float v1)
 
119
{
 
120
  myclass proj;
 
121
 
 
122
  proj.ref() = 0.0f;
 
123
  proj.ref() = -(v1+v0);
 
124
 
 
125
  return proj;
 
126
}
 
127
 
 
128
float &
 
129
myclass::ref()
 
130
{
 
131
  return this->value;
 
132
}
 
133
 
 
134
int
 
135
main(void)
 
136
{
 
137
  myclass proj = hepp(2.0f, 4.0f);
 
138
  return (proj.ref() < 0.0f) ? 0 : 1;
 
139
}
 
140
],
 
141
  [sim_cv_c_gcctwonightysixbug=false],
 
142
  [sim_cv_c_gcctwonightysixbug=true],
 
143
  [sim_cv_c_gcctwonightysixbug=false
 
144
   AC_MSG_WARN([can't check for GCC bug when cross-compiling, assuming it's ok])])
 
145
])
 
146
 
 
147
 
 
148
if $sim_cv_c_gcctwonightysixbug; then
 
149
  SIM_AC_ERROR(c--gcc296bug)
 
150
  $2
 
151
else
 
152
  ifelse([$1], , :, [$1])
 
153
fi
 
154
])