静态库是否避免了名称修改问题? [英] Does static library avoids name mangling issues?

查看:60
本文介绍了静态库是否避免了名称修改问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 Visual Studio 2003 SP1 编写的 C++\MFC 应用程序链接到外部静态库SomeExtStaticLib.lib".我还包括随SomeExtStaticLib.lib"提供的头文件,以在我的应用程序中创建对象.

I have a C++\MFC application written in Visual Studio 2003 SP1 links to an external static library "SomeExtStaticLib.lib". I also include the header files provided with "SomeExtStaticLib.lib" to create the objects in my application.

SomeExtStaticLib.lib 是使用 VC6 构建的静态库.

SomeExtStaticLib.lib is a static library built with VC6.

现在,我正在将我的应用程序迁移到 Visual Studio 2008.

Now, I am migrating my application to Visual Studio 2008.

我有一个非常基本的问题.

I have very basic question.

我是否也应该将SomeExtStaticLib.lib"迁移到 VS2008 编译的一个?当我尝试在我的 VC9 编译应用程序中使用这个 VC6 编译的SomeExtStaticLib.lib"时,它没有给出任何链接器错误.我期待至少有一些名称修改问题.

Should I also migrate the "SomeExtStaticLib.lib" to VS2008 compiled one? When I tried to use this VC6 compiled "SomeExtStaticLib.lib" in my VC9 compiled application it did not give any linker errors. I was expecting at least some name mangling issues.

静态库是否消除了名称修改问题?

Are static libraries eliminating the name mangling issues?

推荐答案

问题不是静态与动态链接之一,也不是真正的名称破坏.问题是使用的所有内容的二进制兼容性之一在界面中.因此,例如,除非我大错特错,std::string 的定义在 VC6 和 VC9 之间改变,带有不同的布局.因此,如果任何代码使用 std::string,您将拥有重新编译,或在运行时出现奇怪且无法解释的错误.

The issue isn't one of static vs. dynamic linking, nor really of name mangling. The issue is one of binary compatibility for everything used in the interface. Thus, for example, unless I'm badly mistaken, the definition of std::string changed between VC6 and VC9, with a different layout. So if any of the code uses std::string, you'll have to recompile, or get strange and unexplicable errors at runtime.

一般来说,最好尽快假设没有二进制兼容性不同版本的编译器,甚至不同的编译涉及选项,除非供应商另有保证.(虽然一些常识是有道理的:您可以自由组合选项,仅例如,控制警告.但要注意 /Ds 导致添加要生成与否的调试代码.)

In general, it's best to assume no binary compatibility as soon as different versions of the compiler, or even different compilation options are involved, unless the vendor guarantees otherwise. (Although some common sense is in order: you can freely mix options which only control warnings, for example. But beware of /Ds which cause added debugging code to be generated or not.)

这篇关于静态库是否避免了名称修改问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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