我如何避免名称变形? [英] How can i avoid name mangling?

查看:130
本文介绍了我如何避免名称变形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

... in c ++

推荐答案

它内置的编译器允许你重载函数,并具有相同的名称在不同的类和这样的东西。但是你可以编写像C函数那样被破坏的函数。这些可以从C代码调用。但是这些不能被重载,并且不能被正常C ++函数指针调用:

You can't. It's built into compilers to allow you overloading functions and to have functions with the same name in different classes and such stuff. But you can write functions that are mangled like C functions. Those can be called from C code. But those can't be overloaded and can't be called by "normal" C++ function pointers:

extern "C" void foo() {

}

上述函数将被类似C函数为您的编译器。这可能包括对名称没有任何改变,或者像它前面的前导_一样的改变。

The above function will be mangled like C functions for your compiler. That may include no change at all to the name, or some changes like a leading "_" in front of it or so.

这篇关于我如何避免名称变形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆