Visual Studio 2019碰到的几个问题(C3861,RC1015,C2039等)

小结

最近在Visual Studio 2019中碰到的几个问题:C3861,RC1015,C2039等,另外还有一个启动调试时碰到‘系统找不到相应的文件’问题,解决了这些问题。

问题及解决

C3861和C2039

error C3861: ‘gets’: identifier not found

对于这个error C3861: 'gets': identifier not found 的问题,自从C11后,gets()已经被 gets_s()所替代,因为gets_s()会进行边界检查,防止边界溢出。

所以将gets()已经被 gets_s()进行替换可以解决问题。

其它的 Identifier not found.C3861和C2039

我这里碰到的是头文件的问题,这里C3861返回的是identifier not found,而C2039返回的是xxx: is not a member of global namespace,需要把库文件头和系统文件头放到最上面。
例如我的#include "RoboticArmJetmax.hpp"移到所有的头文件前面,这两个报错可以神奇消失。

fatal error RC1015: cannot open include file ‘afxres.h’

解决办法比较简单,是由于缺少MFC的包,好像Visual Studio从2015版本后就没有安装MFC包,不需要安装,只需将#include "afxres.h"替换为#include<windows.h>

“The system cannot find the file specified”

开始启动调试时碰到‘系统找不到相应的文件’问题, The system cannot find the file specified, 这里主要是检查工程的属性:工程属性 -> Linker -> Output file -> ( O u t D i r ) (OutDir) (OutDir)(TargetName)$(TargetExt),如果配置不正确就会出现这个问题。

参考

Stackoverflow: gets() function is not available in Visual studio 2015 community
fatal error RC1015: cannot open include file ‘afxres.h’
“The system cannot find the file specified” when running C++ program
Stackoverflow: Identifier not found.C3861
Code project: Solution for C++ error c2039 is not a member of global namespace

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值