加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

vc 警告 C4503 超出修饰名的长度 名称被截断 解决办法

(2014-08-28 18:22:24)
标签:

vc

c4503

修饰名

截断

分类: 想想专业
错误消息
“identifier”: 修饰名的长度超出限制,名称被截断
来自于梦行智科
修饰名的长度超出编译器限制 (4096),被截断了。若要避免出现此警告和截断,请减少所使用的参数数目或标识符的名称长度。
发出此警告的一种情况是当代码重复包含专用于模板的模板时。例如,映射的映射(来自标准 C++ 库)。在这种情况下,可以将您的 typedef 设置为一个包含映射的类型(例如,结构)。
不过,您可能决定不重构自己的代码。可以发布生成 C4503 的应用程序,但如果收到关于截断符号的链接时错误,确定错误中符号的类型将更加困难。调试也将更加困难;调试器将符号名称映射到类型名称也会有困难。但是,程序的正确性不受截断名称的影响。
下面的示例生成 C4503:

 C++ Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
// 警告代码
// C4503.cpp
// compile with: /W1 /EHsc /c
// C4503 expected
#include 〈string〉
#include 〈map〉

class Field{};
typedef std::map〈std::string, Field〉 Screen;
typedef std::map〈std::string, Screen〉 WebApp;
typedef std::map〈std::string, WebApp〉 WebAppTest;
typedef std::map〈std::string, WebAppTest〉 Hello;
Hello MyWAT;

 C++ Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 下面的示例显示了一种通过重写代码来解决 C4503 的方法:
// C4503b.cpp
// compile with: /W1 /EHsc /c
#include 〈string〉
#include 〈map〉

class Field{};
struct Screen2 {
   std::map〈std::string, Field〉 Element;
};

struct WebApp2 {
   std::map〈std::string, Screen2〉 Element;
};

struct WebAppTest2 {
   std::map〈std::string, WebApp2〉 Element;
};

struct Hello2 {
   std::map〈std::string, WebAppTest2〉 Element;
};

Hello2 MyWAT2;

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有