Visual Studio 中的 C++ 头文件
C++ header file in Visual Studio
好的。所以我有一个简单的问题。如果我问错了地方,请指正。我想问的是,为什么 Visual Studio 给我这个:
#include "stdafx.h"
int main()
{
return 0;
}
每次我创建一个新项目? (我知道我可以 select 清空项目,然后自己添加我的 .cpp 文件,但我只是好奇。上面写着 #include <stdio.h>
和 #include <tchar.h>
。那么它有什么用呢?是你们都在用吗?
和 P.S - 为什么 main
声明中没有 (int argc, char** argv)
? (在我大学的编码课程中,我了解到在 VS 中创建内容时可能 _tmain(int argc, _TCHAR* argv)
)
Okay. So I've got a simple question. If I ask it in the wrong place, please correct me. What I want to ask is, why Visual Studio gives me this:
...
好吧,这在一定程度上取决于您从向导中选择的项目类型。看起来像 控制台项目.
的标准模板
#include "stdafx.h"
向导为任何类型的翻译单元添加了前缀。它支持 precompiled header optimizaton mechanism.
why there is no (int argc, char** argv)
in main declaration?
因为模板提供了有效 main()
入口例程定义的最小值。
创建新的 Win32 项目时,Visual Studio 会自动将预编译的 header "stdafx.h" 添加到您的项目,即使您取消选中 'Empty Project' 复选框也是如此。
如果您想禁用它,请转到您的项目配置属性 -> C/C++ -> 预编译 Headers 和 select 'Not Using Precompiled Headers'.
使用预编译 headers 请参阅:https://whosebug.com/a/4726838。
和P.S。看看 -> https://whosebug.com/a/4207223
预编译 header 是为了加快编译时间,它只编译一次您最常包含的 header 的内容,然后重新使用编译结果。如果需要,您可以更改其名称。
好的。所以我有一个简单的问题。如果我问错了地方,请指正。我想问的是,为什么 Visual Studio 给我这个:
#include "stdafx.h"
int main()
{
return 0;
}
每次我创建一个新项目? (我知道我可以 select 清空项目,然后自己添加我的 .cpp 文件,但我只是好奇。上面写着 #include <stdio.h>
和 #include <tchar.h>
。那么它有什么用呢?是你们都在用吗?
和 P.S - 为什么 main
声明中没有 (int argc, char** argv)
? (在我大学的编码课程中,我了解到在 VS 中创建内容时可能 _tmain(int argc, _TCHAR* argv)
)
Okay. So I've got a simple question. If I ask it in the wrong place, please correct me. What I want to ask is, why Visual Studio gives me this: ...
好吧,这在一定程度上取决于您从向导中选择的项目类型。看起来像 控制台项目.
的标准模板#include "stdafx.h"
向导为任何类型的翻译单元添加了前缀。它支持 precompiled header optimizaton mechanism.
why there is no
(int argc, char** argv)
in main declaration?
因为模板提供了有效 main()
入口例程定义的最小值。
创建新的 Win32 项目时,Visual Studio 会自动将预编译的 header "stdafx.h" 添加到您的项目,即使您取消选中 'Empty Project' 复选框也是如此。
如果您想禁用它,请转到您的项目配置属性 -> C/C++ -> 预编译 Headers 和 select 'Not Using Precompiled Headers'.
使用预编译 headers 请参阅:https://whosebug.com/a/4726838。
和P.S。看看 -> https://whosebug.com/a/4207223
预编译 header 是为了加快编译时间,它只编译一次您最常包含的 header 的内容,然后重新使用编译结果。如果需要,您可以更改其名称。