默认情况下,为什么MS Visual Studio #include <stdio.h>在stdafx.h中?

gaa*_*kam 1 c++ stdafx.h visual-studio visual-c++

MS Visual Studio 2017,来自VisualC++类别的新Windows控制台应用程序项目.默认stdafx.h标头包含以下行:

#include <stdio.h>
#include <tchar.h>
Run Code Online (Sandbox Code Playgroud)

在他们下面:

// TODO: reference additional headers your program requires here
Run Code Online (Sandbox Code Playgroud)

因为这个评论被放在下面,而不是上面#include <stdio.h>,我倾向于认为stdio.h默认情况下包含这个评论并不是为了方便用户#include,但是出于某种原因需要它?stdio.h包含而不仅仅是这个事实cstdio似乎支持这种解释?

我对吗?我可以安全地删除#include <stdio.h>吗?我问,因为我main函数的第一行是:

std::ios_base::sync_with_stdio(false);
Run Code Online (Sandbox Code Playgroud)

如果stdio正在使用设施,这显然是不正确的,因为包含的这个标题会提示.

1)我可以安全地删除#include <stdio.h>从中说出的行stdafx.h吗?

2)我可以安全地打电话std::ios_base::sync_with_stdio(false)吗?

3)tchar.h此处默认包含的事实是否相关?

Ale*_*iev 5

是的你可以删除它.

您甚至可以将预编译头命名为stdafx.h,或者根本禁用percompiled头.

这只是方便和榜样的开始.