惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
博客园_首页
T
The Blog of Author Tim Ferriss
H
Hackread – Cybersecurity News, Data Breaches, AI and More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
I
InfoQ
量子位
J
Java Code Geeks
P
Proofpoint News Feed
有赞技术团队
有赞技术团队
Webroot Blog
Webroot Blog
Martin Fowler
Martin Fowler
D
Docker
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
V
Vulnerabilities – Threatpost
罗磊的独立博客
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
Cyberwarzone
Cyberwarzone
P
Privacy & Cybersecurity Law Blog
Last Week in AI
Last Week in AI
爱范儿
爱范儿
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
V
V2EX
Simon Willison's Weblog
Simon Willison's Weblog
AI
AI
Y
Y Combinator Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
V
Visual Studio Blog
H
Heimdal Security Blog
S
Secure Thoughts
B
Blog RSS Feed
雷峰网
雷峰网
T
Tenable Blog
C
Check Point Blog
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
About on SuperTechFans
Recent Commits to openclaw:main
Recent Commits to openclaw:main

博客园 - 千里马肝

模型数据作渲染优化时遇到的问题 vertex compression所遇到的问题 depth and distance Linear or non-linear shadow maps? 实施vertex compression所遇到的各种问题和解决办法 【转】編譯Ogre1.9 IOS Dependencies及Ogre Source步驟及相關注意事項… 画之国 Le tableau (2011) 关于H.264 x264 h264 AVC1 解决Visual Studio 2010/2012在调试时lock文件的方法 神片和神回复 3DS Max 2014 features revealed 【西川善司】PLAYSTATION4图形讲座(后篇) [ 【西川善司】PLAYSTATION4图形讲座(前篇) 趣文:程序员/开发人员的真实生活 【转】25 things you probably didn't know about the 3ds Max SDK [讣告]“D之食卓”等代表作制作人饭野贤治逝世 楚汉传奇 【翻译】揭晓「Agni's Philosophy」幕后的"技术编" 【PS3/XB360】DEAD OR ALIVE 5 制作采访
解决Visual Studio 2010/2012的RC4011 warnings
千里马肝 · 2013-09-12 · via 博客园 - 千里马肝

如果在vc10/11工程的rc文件中有以下任意一行代码:

#include <winuser.h>
#include <richedit.h>

那么vc将会给出一对警告:

C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string.h(54): warning RC4011: identifier truncated to '_CRT_SECURE_CPP_OVERLOAD_STANDA'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string.h(76): warning RC4011: identifier truncated to '_CRT_SECURE_CPP_OVERLOAD_SECURE'

其原因是vc提供了一个宏_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_MEMORY,用来自动将代码中的memcpy替换成memcpy_s。
memcpy_s在被提出时,确实感觉这样子代码是安全了,但是两个函数的参数不一致,导致修改量上去了,而且移植性也没有了,于是vc好心地提供这个宏用来自动替换。
那么为什么会有上面的警告呢?

问题出在RC,也就是resource compiler,基于历史原因,它会自动将长度超过31的宏截断,应该是RC只用了char[32]来存诸的缘故,于是我们就看到让人不舒服的警告了。

解决办法很简单:

针对#include <winuser.h>,将其替换为<windows.h>。

针对#include <richedit.h>,稍微麻烦一点。
据我们所知,rc包含.h的目的通常只是为了一些#define,对其中的函数神马的并不在意。
那么如警告中描述所示,问题是出在string.h,同时我们包含richedit其实也只是为了得到RICHEDIT_CLASS,那么事情好办了,修改如下:

#ifdef RC_INVOKED
#define _INC_STRING
#endif

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"

如MSDN中所描述:

To conditionally compile your code with the RC compiler, surround code that RC cannot compile with #ifndef RC_INVOKED and #endif.

而string.h中是这样定义的:

#pragma once

#ifndef _INC_STRING
#define _INC_STRING

...

#endif

好的,你懂的,我就不多说什么了。

:D