我在过去使用了以下函数来分解c++符号,它被证明是非常有用的:
char* __cxa_demangle(const char* __mangled_name, char* __output_buffer, size_t* __length, int* __status);
现在我使用的是一个使用gcc的C应用程序,但不能使用__cxa_demangle,因为它是一个C程序(它只在C++编译器g++中可用),在C++中我通常会这样调用:
abi::__cxa_demangle(mangled.c_str(), NULL, 0, 0);
有人知道如何在C中实现同样的功能吗?
发布于 2019-09-18 17:21:51
在源代码的注释中回答了我自己的问题:
* @note The same demangling functionality is available via
* libiberty (@c <libiberty/demangle.h> and @c libiberty.a) in GCC
* 3.1 and later, but that requires explicit installation (@c
* --enable-install-libiberty) and uses a different API, although
* the ABI is unchanged.
*/
char*
__cxa_demangle(const char* __mangled_name, char* __output_buffer,
size_t* __length, int* __status);
https://stackoverflow.com/questions/57989227
复制相似问题