【原创】使用 VS 编译遇到的一些 error 和 warning(持续更新)

简介:


error C2143

?
1
error C2143: 语法错误 : 缺少“;”(在“类型”的前面)

原因:以“编译为 C 代码(/TC)”方式编译时,没有把变量定义在函数开始的位置。

error LNK2019

?
1
error LNK2019: 无法解析的外部符号 _abc,该符号在函数 _xyz 中被引用

原因:
当前源文件 xyz 中使用了外部符号 abc ,但是无法找到该符号,原因是没有包含对应的 .lib 库文件。
另外可能的原因:

  • 包含了 .lib 库但是没有将相应的符号 abc 导出
  • 还有一种情况是由于头文件和库文件不匹配造成

【error C2733】

?
1
error C2733: second C linkage of overloaded function 'wmemchr' not allowed

原因:针对处于 C++ 模式下的 VC6 以及其它 VS 版本,当进行 ARM 相关编译时应该对要使用的 <wchar.h> 头文件进行 'extern "C++" {}' 处理。

?
1
2
3
4
5
6
7
8
9
#ifdef __cplusplus
extern "C" {
#endif
 
#  include <wchar.h>
 
#ifdef __cplusplus
}
#endif

【error C2440】

?
1
error C2440: “=”: 无法从“void *”转换为“void **”

原因:一般会在调用 malloc 函数后将其返回值赋值给其他变量时出现,值得注意的是,出现该错误的前提是按照“编译为 C++ 代码 (/TP)”进行编译,如果按照“编译为 C 代码 (/TC)”进行编译则不会出现该错误。

【error C2054】

?
1
error C2054: 在“inline”之后应输入“(”
原因:这个错误出现在以“  编译为 C 代码 (/TC)   ”进行编译时,内联函数使用 inline 来标示,而没有使用 __inline 标识。可以在  以“   编译为 C 代码 (/TC)   ”进行编译时,增加宏定义 #define inline __inline 。


【Warning C4251】

?
1
2
warning C4251: 'AClass::m_variable' : class 'SomeTemplate<T>' needs
to have dll-interface to be used by clients of class 'AClass'

原因: 牛逼文章1、 文章2


Warning C4996

?
1
warning C4996: 'strdup' : The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup.
?
1
warning C4996: 'sprintf' : This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

原因:详细原因需要参考MSDN上的官方说明


目录
相关文章
|
3天前
|
JSON 编译器 开发工具
VS Code阅读Android源码
VS Code阅读Android源码
10 1
|
6月前
|
缓存 Cloud Native JavaScript
猫头虎的技术博客:解决npm报错 npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题
猫头虎的技术博客:解决npm报错 npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题
115 0
|
Perl 网络协议 消息中间件
|
8月前
|
算法 程序员
《Clean Code》读书笔记
《Clean Code》读书笔记
|
C++ Windows
全网首发:编译ffmpeg: error: ‘VFW_E_NOT_FOUND‘ undeclared ; did you mean ‘NTE_NOT_FOUND‘?
全网首发:编译ffmpeg: error: ‘VFW_E_NOT_FOUND‘ undeclared ; did you mean ‘NTE_NOT_FOUND‘?
118 0
|
前端开发 JavaScript
uniapp真机调试文件查找失败:‘./pages/index/index.nvue?mpType=page‘; Error: Cannot find module ‘pages/ ———————————————— 版权声明:本文为CSDN博主「前端老实人」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/weixin_52691965/article/details/119241451
uniapp真机调试文件查找失败:‘./pages/index/index.nvue?mpType=page‘; Error: Cannot find module ‘pages/ ———————————————— 版权声明:本文为CSDN博主「前端老实人」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/weixin_52691965/article/details/119241451
全网首发:doubango提示text relocations错误的解决办法
全网首发:doubango提示text relocations错误的解决办法
168 0