如何增加 VC9 (MSVC 2008) 中允许的修饰名称长度?
我有一组相当大且复杂的程序要从 VC8 移植到 VC9。 其中一个模块具有许多分层的 typedef,这会导致编译器生成 C4503 警告(修饰名被截断)。 生成的LIB文件将无法正确链接到项目中的其他模块。 VC8 对此没有遇到任何问题,这让我得出结论,要么修饰过程已更改以生成更长的名称,要么修饰名称长度的内部限制已减少。 克服这个问题的最佳方法是什么?
由于遗留代码的原因,MSDN 建议用结构替换 typedef 是不切实际的。
有问题的 typedef 是(经过清理的代码):
enum Type{
TYPE_COUNT,
TYPE_VALUE
};
typedef MyVector< Container*, CriticalSectionLock > Containers;
typedef MyVector< MyClassType*, CriticalSectionLock >::const_iterator const_iterator_type;
typedef MyVector< stl::pair< string, Type > >::const_iterator const_iterator_def;
typedef MyVector< Container** >::const_iterator const_iterator_container;
typedef MyVector< stl::pair < MyBase*, MyVector< stl::pair< Container**, Containers* > > > >::const_iterator const_iterator;
I have a rather large and complex set of programs to port from VC8 to VC9. One of the modules has a number of layered typedefs, which cause the compiler to generate a C4503 warning (decorated name truncated). The generated LIB file will not properly link to other modules in the project. VC8 had no trouble with this, leading me to conclude that either the decoration process has changed to generate even longer names, or the internal limit for the length of a decorated name has decreased. What's the best way to get over this?
For legacy code reasons, the MSDN suggestion of replacing typedefs with structs is not practical.
The typedefs in question are (sanitized code):
enum Type{
TYPE_COUNT,
TYPE_VALUE
};
typedef MyVector< Container*, CriticalSectionLock > Containers;
typedef MyVector< MyClassType*, CriticalSectionLock >::const_iterator const_iterator_type;
typedef MyVector< stl::pair< string, Type > >::const_iterator const_iterator_def;
typedef MyVector< Container** >::const_iterator const_iterator_container;
typedef MyVector< stl::pair < MyBase*, MyVector< stl::pair< Container**, Containers* > > > >::const_iterator const_iterator;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于似乎没有办法增加编译器对修饰名称长度的内部限制,因此我硬着头皮进行了 MSDN 中建议的更改。 请参阅: http://msdn.microsoft.com/en-us/library/ 074af4b6.aspx
我只需要将第一个 typedef 更改为结构体。 这需要对遗留代码进行大约 200 个其他更改,这很乏味,但在其他方面并不困难。 然而,我将在下周左右进行回归测试,以确保这不会搞砸一些事情。
这是基本的更改:(请注意,我被迫向结构添加一些 ctor)
Since there does not appear to be a way to increase the compiler's internal limitation on the decorated name length, I bit the bullet and made the change suggested in the MSDN. see: http://msdn.microsoft.com/en-us/library/074af4b6.aspx
I only had to change the first typedef to a struct. This required about 200 other changes in legacy code, which was tedious, but otherwise not difficult. However, I will be spending the next week or so in regression testing to make sure this did not screw something up.
Here is the basic change: (note that I was forced to add some ctors to the struct)
人的一生太短了。
Life's too short man.
@Roel:正如我在原始帖子中提到的:“生成的 LIB 文件将无法正确链接到项目中的其他模块。”
IOW,这不仅仅是一个“警告”。 它导致项目无法运行。
我发布的修复程序完全实施起来有些困难和乏味,但它确实有效。
@Roel: As I mentioned in the original posting: "The generated LIB file will not properly link to other modules in the project."
IOW, this is more than just a 'warning'. It causes the project NOT TO WORK.
My posted fix is somewhat difficult and tedious to completely implement, but it does work.