的Visual Studio 2012的编译时间
问题描述:
可能重复:
Why does C++ compilation take so long?
Visual studio 2012 slow compile time的Visual Studio 2012的编译时间
我使用的Visual Studio 2012,它需要编译时间的方式来长。大约20秒只需要50行代码。我认为这是我的电脑故障,但C#编译罚款只是不是C + +。我知道C++编译需要更长的时间,但20秒很荒谬。
下面是我正在编译的代码,需要大约20秒才能编译。
#include<iostream>
using namespace std;
class Entity
{
protected:
int health;
public:
void SetHealth(int value)
{
health = value;
}
void DisplayHealth()
{
cout << "Entity: " << health << endl;
}
};
class Player : public Entity
{
private:
int xp;
public:
void DisplayHealth()
{
cout << "Player: " << health << endl;
}
};
class Enemy : public Entity
{
};
int main()
{
Player player;
Entity *entity = &player;
entity->SetHealth(10);
player.DisplayHealth();
system("pause");
return 0;
}
我的代码不应该花20秒来编译。使用visual studio 2010的编译时间并不慢,而且与code :: blocks相同。不是Visual Studio 2012应该是一种改进? – CodingMadeEasy
你使用预编译头文件吗?看起来你不是来自上面的代码。尝试使用它们,看看你的编译时间是否提高。 – john
预编译头文件不会对一个文件项目产生很大影响。我在Visual Studio 2008和2010中编译了代码,并且在调试或发布模式下编译器都花费了大约1秒的时间。我没有2012年测试。 –