+-

我正在尝试在Visual Studio社区2017上构建解决方案,但我不断收到错误“无法打开包含文件:’stdio.h’”.我已经阅读了几个类似的问题,但仍然无法解决这个问题.看起来在stdafx.h文件中调用了stdio.h文件.以下是更多细节.有什么建议么? (我无法嵌入图片,所以请点击链接进行截图.)
系统细节:
Windows 10
Visual Studio Community 2017 v.15.2(26430.6)
– 使用C安装桌面开发(Screenshot: Installation list)
第1步:我用C编写了着名的Hello World程序.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
第2步:我点击Build>构建解决方案
问题:’stdio.h’:没有这样的文件或目录.完全错误:
1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1>stdafx.cpp
1>c:\users\dahiana mini\desktop\learncpp\helloworld\helloworld\stdafx.h(10):
fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
1>Done building project "HelloWorld.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
故障排除详细信息/我尝试过的事情:
>配置属性> VC目录
包含目录$(VC_IncludePath); $(WindowsSDK_IncludePath);
> Screenshot: Solution Explorer (files in the project)
> stdafx.cpp文件中的代码:
// stdafx.cpp : source file that includes just the standard includes
// HelloWorld.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
> stdafx.h文件中的代码:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
注意:< stdio.h>的#include;和< tchar.h>两者都有下面的红色波浪线,并说“无法打开源文件”.
TRIED:我尝试删除最后两行,但后来我遇到了更多错误.
> TRIED:由于许多人认为不需要stdafx.h,我试图只删除第一行#include“stdafx.h”.但为了实现这一点,我必须多做一点.请看下面的答案.
最佳答案
项目从VS2013移植到VS2017时出现同样的问题,
修复:将“属性 – >常规 – > Windows SDK版本”更改为10
修复:将“属性 – >常规 – > Windows SDK版本”更改为10
点击查看更多相关文章
转载注明原文:无法打开包含文件:’stdio.h’ – Visual Studio社区2017 – C错误 - 乐贴网