0

Possible Duplicate:
Why does C++ compilation take so long?
Visual studio 2012 slow compile time

I'm using visual studio 2012 and the time it takes to compile is way to long. About 20 seconds just for a measly 50 lines of code. I thought it was my computers fault but c# compiles fine on it just not c++. I know that c++ takes longer to compile but 20 seconds is ridiculous.

Here's the code I'm trying to compile which takes about 20 seconds to compile.

#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;
}
Community
  • 1
  • 1
CodingMadeEasy
  • 2,257
  • 4
  • 19
  • 31
  • My code shouldn't be taking 20 seconds to compile. Using visual studio 2010 the compile times weren't that slow and same with code::blocks. Isn't visual studio 2012 supposed to be an improvement? – CodingMadeEasy Oct 25 '12 at 07:35
  • Are you using precompiled headers? Looks like you aren't from the code above. Try using them and see if your compilation times improve. – john Oct 25 '12 at 07:45
  • 2
    Precompiled headers aren't going to make a big difference in a one file project. I compiled your code in Visual Studio 2008 and 2010 and it took ~1 second for both compilers in either debug or release mode. I don't have 2012 to test with. – Retired Ninja Oct 25 '12 at 07:52
  • why do you ask [exactly the same question](http://stackoverflow.com/questions/13057396/visual-studio-2012-slow-compile-time) again? You shouldn't. – Lol4t0 Oct 25 '12 at 08:02

1 Answers1

3

I've compiled this piece of code under my installation of VS2012 and it took about 3 seconds to build a project with this only file. Probably, you have troubles in your VS2012 installation. Try running it in safe mode to disable extensions.

Mikhail
  • 20,685
  • 7
  • 70
  • 146