ax_cxx_gcc_abi_demangle.m4 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #serial 10
  27. AC_DEFUN([AX_CXX_GCC_ABI_DEMANGLE],
  28. [AC_PREREQ([2.63])dnl
  29. AC_CACHE_CHECK([whether the compiler supports GCC C++ ABI name demangling],
  30. [ax_cv_cxx_gcc_abi_demangle],
  31. [AC_LANG_PUSH([C++])
  32. AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <typeinfo>
  33. #include <cxxabi.h>
  34. #include <cstdlib>
  35. #include <string>
  36. template<typename TYPE>
  37. class A {};]],
  38. [[A<int> instance;
  39. #if defined(_WIN32)
  40. return EXIT_FAILURE;
  41. #endif
  42. int status = 0;
  43. char* c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status);
  44. std::string name(c_name);
  45. ::free(c_name);
  46. if (name.compare("A<int>") != 0)
  47. {
  48. return EXIT_FAILURE;
  49. }]])],
  50. [ax_cv_cxx_gcc_abi_demangle=yes],
  51. [ax_cv_cxx_gcc_abi_demangle=no],
  52. [ax_cv_cxx_gcc_abi_demangle=no])
  53. AC_LANG_POP])
  54. AC_MSG_CHECKING([checking for cxx_gcc_abi_demangle])
  55. AC_MSG_RESULT(["$ax_cv_cxx_gcc_abi_demangle"])
  56. AS_IF([test "x$ax_cv_cxx_gcc_abi_demangle" = xyes],
  57. [AC_DEFINE([HAVE_GCC_ABI_DEMANGLE],[1],[define if the compiler supports GCC C++ ABI name demangling])])
  58. ])