monotone

monotone Mtn Source Tree

Root/m4/tempstatconst.m4

1# check for the obnoxious gcc 4.1.[01] template static data bug
2# (see http://gcc.gnu.org/PR28016)
3AC_DEFUN([AC_CXX_TEMPLATE_STATIC_CONST_BUG],
4[AC_LANG_ASSERT([C++])
5 code='
6 template<class T> struct S { static const bool B; };
7 template<class T> const bool S<T>::B = true;'
8
9 codeA="
10 $code
11 int foo() { return 0; }"
12
13 codeB="
14 $code
15 extern int foo();
16 int main() { return foo(); }"
17
18 AC_CACHE_CHECK(
19 [whether $CXX handles templates with static const members correctly],
20 ac_cv_prog_cxx_template_static_const_ok,
21 [
22 # Autoconf doesn't make it easy to do a test involving
23 # linking two files. This is the best way I know of.
24 AC_COMPILE_IFELSE([$codeA],
25 [mv conftest.$ac_objext conftestA.$ac_objext
26 save_LIBS="$LIBS"
27 LIBS=conftestA.$ac_objext
28 AC_LINK_IFELSE([$codeB],
29 [ac_cv_prog_cxx_template_static_const_ok=yes],
30 [ac_cv_prog_cxx_template_static_const_ok=no])
31 LIBS="$save_LIBS"],
32 [ac_cv_prog_cxx_template_static_const_ok=no])
33 ])
34if test $ac_cv_prog_cxx_template_static_const_ok = no; then
35 # ??? This is the correct workaround for g++ and gnu ld, but maybe not
36 # for others. (But this is a GNU-specific bug, so...)
37 LDFLAGS="$LDFLAGS -Wl,-z,muldefs"
38fi
39])

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status