# abi Namespace Reference

## Detailed Description

A brief overview of an ABI is given in the libstdc++ FAQ, question 5.8 (you may have a copy of the FAQ locally, or you can view the online version at http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#5_8).

GCC subscribes to a relatively-new cross-vendor ABI for C++, sometimes called the IA64 ABI because it happens to be the native ABI for that platform. It is summarized at http://www.codesourcery.com/cxx-abi/ along with the current specification.

For users of GCC greater than or equal to 3.x, entry points are available in <cxxabi.h>, which notes, "It is not normally necessary for user programs to include this header, or use the entry points directly. However, this header is available should that be needed."

## Functions

- char * __cxa_demangle (const char *mangled_name, char *output_buffer, size_t *length, int *status)

## Function Documentation

char* abi::__cxa_demangle | ( | const char * | mangled_name,
|  | char * | output_buffer,
|  | size_t * | length,
|  | int * | status |
| ) |  |  |

New ABI-mandated entry point in the C++ runtime library for demangling.

Parameters:

  | mangled_name | A NUL-terminated character string containing the name to be demangled.
  | output_buffer | A region of memory, allocated with malloc, of *length bytes, into which the demangled name is stored. If output_buffer is not long enough, it is expanded using realloc. output_buffer may instead be NULL; in that case, the demangled name is placed in a region of memory allocated with malloc.
  | length | If length is non-NULL, the length of the buffer containing the demangled name is placed in *length.

  status

  *status is set to one of the following values:
  - 0: The demangling operation succeeded.
  - -1: A memory allocation failiure occurred.
  - -2: mangled_name is not a valid name under the C++ ABI mangling rules.
  - -3: One of the arguments is invalid.

Returns:
  A pointer to the start of the NUL-terminated demangled name, or NULL if the demangling fails. The caller is responsible for deallocating this memory using `free`.

The demangling is performed using the C++ ABI mangling rules, with GNU extensions. For example, this function is used in __gnu_cxx::__verbose_terminate_handler. See http://gcc.gnu.org/onlinedocs/libstdc++/18_support/howto.html#5 for other examples of use.

Note:
  The same demangling functionality is available via libiberty (`<libiberty/demangle.h>` and `libiberty.a`) in GCC 3.1 and later, but that requires explicit installation (`--enable-install-libiberty`) and uses a different API, although the ABI is unchanged.