Updating m4
[m6w6/libmemcached] / m4 / ax_cxx_gcc_abi_demangle.m4
1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_cxx_gcc_abi_demangle.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_CXX_GCC_ABI_DEMANGLE
8 #
9 # DESCRIPTION
10 #
11 # If the compiler supports GCC C++ ABI name demangling (has header
12 # cxxabi.h and abi::__cxa_demangle() function), define
13 # HAVE_GCC_ABI_DEMANGLE
14 #
15 # Adapted from AX_CXX_RTTI by Luc Maisonobe
16 #
17 # LICENSE
18 #
19 # Copyright (c) 2012 Brian Aker <brian@tangent.org>
20 # Copyright (c) 2008 Neil Ferguson <nferguso@eso.org>
21 #
22 # Copying and distribution of this file, with or without modification, are
23 # permitted in any medium without royalty provided the copyright notice
24 # and this notice are preserved. This file is offered as-is, without any
25 # warranty.
26
27 #serial 9
28
29 AC_DEFUN([AX_CXX_GCC_ABI_DEMANGLE],
30 [AC_CACHE_CHECK([whether the compiler supports GCC C++ ABI name demangling],
31 [ax_cv_cxx_gcc_abi_demangle],
32 [AC_LANG_PUSH([C++])
33 AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <typeinfo>
34 #include <cxxabi.h>
35 #include <cstdlib>
36 #include <string>],
37 [template<typename TYPE>
38 class A {};
39 ],[A<int> instance;
40 int status = 0;
41 char* c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status);
42
43 std::string name(c_name);
44 ::free(c_name);
45
46 return name == "A<int>";
47 ])],[ax_cv_cxx_gcc_abi_demangle=yes],
48 [ax_cv_cxx_gcc_abi_demangle=no],
49 [ax_cv_cxx_gcc_abi_demangle=no])
50 AC_LANG_POP])
51 AS_IF([test "x$ax_cv_cxx_gcc_abi_demangle" = xyes],
52 [AC_DEFINE([HAVE_GCC_ABI_DEMANGLE],[1],[define if the compiler supports GCC C++ ABI name demangling])])
53 ])