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

文章目录

  • 小结
  • 问题及解决
  • C3861和C2039
    • error C3861: 'gets': identifier not found
    • 其它的 Identifier not found.C3861和C2039
  • fatal error RC1015: cannot open include file 'afxres.h'
  • "The system cannot find the file specified"
  • 参考

小结

最近在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

“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

你可能感兴趣的:(C/C++)