[英]Why does MS Visual Studio #include <stdio.h> in stdafx.h by default?
MS Visual Studio 2017,VisualC ++类别中的新Windows控制台应用程序项目。 默认的stdafx.h
标头包含以下几行:
#include <stdio.h>
#include <tchar.h>
在它们下面:
// TODO: reference additional headers your program requires here
因为此注释放在下面,而不是在#include <stdio.h>
之上,所以我倾向于认为默认情况下包括stdio.h
并不是为了方便可能会#include
它的用户使用,但是出于某种原因需要? 包括stdio.h
而不是cstdio
的事实似乎仅支持这种解释?
我对吗? 我可以安全地删除#include <stdio.h>
吗? 我问是因为我main
功能的第一行显示为:
std::ios_base::sync_with_stdio(false);
如果仍然使用stdio
设施,这显然是不正确的,因为包含此标头可能会建议这样做。
1)我可以从stdafx.h
安全删除表示#include <stdio.h>
的行吗?
2)我可以安全地调用std::ios_base::sync_with_stdio(false)
吗?
3)此处默认还包含tchar.h
的事实是否与此相关?
是的,您可以将其删除。
您甚至可以命名您的预编译头而不是stdafx.h,或者完全禁用预编译头。
首先只是方便和示例。
如果您要使用它,则取决于您,但是在删除它之前,请在此MSDN上阅读有关预编译的头文件的信息。
希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.