When I compile my code, I get these errors:

------ Build started: Project: engine, Configuration: Debug Win32 ------
Compiling...
baseanimating.cpp
c:\program files\microsoft visual studio 9.0\vc\include\time.h(39) : error C2143: syntax error : missing ';' before 'string'
c:\program files\microsoft visual studio 9.0\vc\include\time.h(39) : error C2059: syntax error : 'string'
c:\program files\microsoft visual studio 9.0\vc\include\time.h(39) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio 9.0\vc\include\time.h(39) : error C2447: '{' : missing function header (old-style formal list?)
c:\program files\microsoft visual studio 9.0\vc\include\ctime(19) : error C2039: 'clock_t' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(19) : error C2873: 'clock_t' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 9.0\vc\include\ctime(21) : error C2039: 'asctime' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(21) : error C2873: 'asctime' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 9.0\vc\include\ctime(21) : error C2039: 'clock' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(21) : error C2873: 'clock' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 9.0\vc\include\ctime(21) : error C2039: 'ctime' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(21) : error C2873: 'ctime' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 9.0\vc\include\ctime(22) : error C2039: 'difftime' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(22) : error C2873: 'difftime' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 9.0\vc\include\ctime(22) : error C2039: 'gmtime' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(22) : error C2873: 'gmtime' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 9.0\vc\include\ctime(22) : error C2039: 'localtime' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(22) : error C2873: 'localtime' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 9.0\vc\include\ctime(23) : error C2039: 'mktime' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(23) : error C2873: 'mktime' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 9.0\vc\include\ctime(23) : error C2039: 'strftime' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(23) : error C2873: 'strftime' : symbol cannot be used in a using-declaration
c:\program files\microsoft visual studio 9.0\vc\include\ctime(23) : error C2039: 'time' : is not a member of '`global namespace''
c:\program files\microsoft visual studio 9.0\vc\include\ctime(23) : error C2873: 'time' : symbol cannot be used in a using-declaration
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(7) : error C2146: syntax error : missing ';' before identifier 'counter'
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(11) : error C2061: syntax error : identifier 'clock_t'
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(9) : error C2614: 'CTimer' : illegal member initialization: 'counter' is not a base or member
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(13) : error C2065: 'clock_t' : undeclared identifier
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(13) : error C2146: syntax error : missing ';' before identifier 'tick'
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(13) : error C2065: 'tick' : undeclared identifier
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(13) : error C2039: 'clock' : is not a member of 'std'
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(13) : error C3861: 'clock': identifier not found
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(15) : error C2065: 'tick' : undeclared identifier
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(15) : error C2065: 'counter' : undeclared identifier
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(15) : error C2065: 'ms' : undeclared identifier
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(17) : error C2065: 'counter' : undeclared identifier
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\timer.h(17) : error C2065: 'tick' : undeclared identifier
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\baseanimating.cpp(28) : warning C4018: '<' : signed/unsigned mismatch
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\baseanimating.cpp(39) : warning C4018: '<' : signed/unsigned mismatch
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\baseanimating.cpp(50) : warning C4018: '<' : signed/unsigned mismatch
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\baseanimating.cpp(61) : warning C4018: '<' : signed/unsigned mismatch
c:\documents and settings\tom\my documents\visual studio 2008\projects\engine\engine\baseanimating.cpp(72) : warning C4018: '<' : signed/unsigned mismatch
Build log was saved at "file://c:\Documents and Settings\tom\My Documents\Visual Studio 2008\Projects\engine\engine\Debug\BuildLog.htm"
engine - 39 error(s), 5 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The only file that is mine out of those errors is time.h:

#ifndef TIMER_H
#define TIMER_H

#include <ctime>

class CTimer {
    clock_t counter;
public:
    CTimer(): counter(0) {}

    bool elasped(clock_t ms)
    {
        clock_t tick = std::clock();

        if(tick - counter >= ms)
        {
             counter = tick;
             return true;
        }

        return false;
    }
};

#endif //TIMER_H

Can someone help me to fix these errors?

>>The only file that is mine out of those errors is time.h

name your heder file something else because your header file named time.h is most likely conflicting with the standard heder file time.h. namespaces do not resolve conflicts of file names.

Without seeing the rest of the code I can't tell you why those errors occur in the standard library time.h file. Post baseanimating.cpp (or just attach it if it is pretty large file)

Header File(baseanimating.h):

//---------------------------------------------//
// Copyright Tom Tetlaw(C) 2010
//-----------------------------------------//

#ifndef BASEANIMATING_H
#define BASEANIMATING_H

#include "DarkGDK.h"
#include "baseentity.h"
#include "defines.h"
#include "vector.h"
#include <vector>

typedef struct{
	int id;
	char *name;
	char *filename;
}anim;

class CBaseAnimating : public CBaseEntity{
	VEC m_vPosition;
	std::vector<anim> m_vAnimations;
	anim m_aCurrentAnimation;
public:
	DECLARE_CLASS( CBaseAnimating, CBaseEntity );

	CBaseAnimating( );
	~CBaseAnimating( );

	VEC GetPosition( );
	std::vector<anim> GetAnimationsVector( );

	void SetPosition( VEC vPosition );
	
	void AddAnimation( char *pName, char *pFileName );
	void SetAnimation( char *pName );
	void PlayAnimation( char *pName );
	void PauseAnimation( char *pName );
	void ResumeAnimation( char *pName );
	void StopAnimation( char *pName );
}

#endif //BASEANIMATING_H

.cpp file:

#include "baseanimating.h"
#include "globals.h"

CBaseAnimating::CBaseAnimating( )
:m_vPosition( 0, 0, 0 )
{
	gpGlobals.controller.AddEntity( this );
}

void CBaseAnimating::SetPosition( VEC vPosition )
{
	m_vPosition = vPosition;
	dbPositionObject( BaseClass::GetModelID( ), m_vPosition.x, m_vPosition.y, m_vPosition.z );
}

void CBaseAnimating::AddAnimation( char *pName, char *pFileName )
{
	anim aNew;
	aNew.name = pName;
	aNew.filename = pFileName;
	aNew.id = gpGlobals.anim_id_manager.GetNextID( );

	m_vAnimations.push_back( aNew );
}

void CBaseAnimating::SetAnimation( char *pName )
{
	for( int i = 0; i < m_vAnimations.size( ); ++i )
	{
		if( m_vAnimations[i].name == pName )
		{
			m_aCurrentAnimation = m_vAnimations[i];
		}
	}
}

void CBaseAnimating::PlayAnimation( char *pName )
{
	for( int i = 0; i < m_vAnimations.size( ); ++i )
	{
		if( m_vAnimations[i].name == pName )
		{
			dbPlayAnimation( m_vAnimations[i].id );
		}
	}
}

void CBaseAnimating::PauseAnimation( char *pName )
{
	for( int i = 0; i < m_vAnimations.size( ); ++i )
	{
		if( m_vAnimations[i].name == pName )
		{
			dbPauseAnimation( m_vAnimations[i].id );
		}
	}
}

void CBaseAnimating::ResumeAnimation( char *pName )
{
	for( int i = 0; i < m_vAnimations.size( ); ++i )
	{
		if( m_vAnimations[i].name == pName )
		{
			dbResumeAnimation( m_vAnimations[i].id );
		}
	}
}

void CBaseAnimating::StopAnimation( char *pName )
{
	for( int i = 0; i < m_vAnimations.size( ); ++i )
	{
		if( m_vAnimations[i].name == pName )
		{
			dbStopAnimation( m_vAnimations[i].id );
		}
	}
}
This article has been dead for over six months. Start a new discussion instead.