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

推荐订阅源

S
Schneier on Security
B
Blog RSS Feed
V
V2EX
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
L
LINUX DO - 热门话题
WordPress大学
WordPress大学
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
T
Threatpost
P
Privacy International News Feed
博客园 - Franky
Spread Privacy
Spread Privacy
K
Kaspersky official blog
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
L
Lohrmann on Cybersecurity
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Exploit Database - CXSecurity.com
GbyAI
GbyAI
T
Tenable Blog
C
Cisco Blogs
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
I
Intezer
J
Java Code Geeks
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Y
Y Combinator Blog
月光博客
月光博客
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
H
Help Net Security
D
Docker
M
MIT News - Artificial intelligence
AWS News Blog
AWS News Blog
Security Latest
Security Latest
C
CERT Recently Published Vulnerability Notes
Blog — PlanetScale
Blog — PlanetScale
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threat Research - Cisco Blogs
T
Tor Project blog
The Cloudflare Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 千里马肝

模型数据作渲染优化时遇到的问题 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