[317c14] | 1 | # ============================================================================ |
---|
| 2 | # https://www.gnu.org/software/autoconf-archive/ax_cxx_gcc_abi_demangle.html |
---|
| 3 | # ============================================================================ |
---|
[56bce65] | 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) 2008 Neil Ferguson <nferguso@eso.org> |
---|
| 20 | # |
---|
| 21 | # Copying and distribution of this file, with or without modification, are |
---|
| 22 | # permitted in any medium without royalty provided the copyright notice |
---|
| 23 | # and this notice are preserved. This file is offered as-is, without any |
---|
| 24 | # warranty. |
---|
| 25 | |
---|
[317c14] | 26 | #serial 10 |
---|
[56bce65] | 27 | |
---|
| 28 | AC_DEFUN([AX_CXX_GCC_ABI_DEMANGLE], |
---|
| 29 | [AC_CACHE_CHECK(whether the compiler supports GCC C++ ABI name demangling, |
---|
| 30 | ax_cv_cxx_gcc_abi_demangle, |
---|
[317c14] | 31 | [AC_LANG_PUSH([C++]) |
---|
| 32 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <typeinfo> |
---|
[56bce65] | 33 | #include <cxxabi.h> |
---|
| 34 | #include <string> |
---|
| 35 | |
---|
| 36 | template<typename TYPE> |
---|
| 37 | class A {}; |
---|
[317c14] | 38 | ]], [[A<int> instance; |
---|
[56bce65] | 39 | int status = 0; |
---|
| 40 | char* c_name = 0; |
---|
| 41 | |
---|
| 42 | c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status); |
---|
| 43 | |
---|
| 44 | std::string name(c_name); |
---|
| 45 | free(c_name); |
---|
| 46 | |
---|
| 47 | return name == "A<int>"; |
---|
[317c14] | 48 | ]])], |
---|
| 49 | [ax_cv_cxx_gcc_abi_demangle=yes], [ax_cv_cxx_gcc_abi_demangle=no]) |
---|
| 50 | AC_LANG_POP([C++]) |
---|
[56bce65] | 51 | ]) |
---|
| 52 | if test "$ax_cv_cxx_gcc_abi_demangle" = yes; then |
---|
| 53 | AC_DEFINE(HAVE_GCC_ABI_DEMANGLE,1, |
---|
| 54 | [define if the compiler supports GCC C++ ABI name demangling]) |
---|
| 55 | fi |
---|
| 56 | ]) |
---|
[317c14] | 57 | |
---|