Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error C2146 in winnt.h?!

Status
Not open for further replies.

ADoozer

Programmer
Dec 15, 2002
3,487
AU
i know this is a basic error.. and im sure ive seen/solved it before but i need sleep and its driving me mad.

im getting the following error when trying to compile very simple code.

C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\winnt.h(152) : error C2146: syntax error : missing ';' before identifier 'WCHAR'

now im pretty sure theres nothing wrong with my winnt header file, can anyone spot my error cos i surely cant.

(PS: ive used these files in another project and they worked fine)

AccurateTimer.h
Code:
// AccurateTimer.h: interface for the AccurateTimer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ACCURATETIMER_H__83F795EC_A278_499B_BD11_73B17E05FF69__INCLUDED_)
#define AFX_ACCURATETIMER_H__83F795EC_A278_499B_BD11_73B17E05FF69__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <winnt.h>
#include <winbase.h>
#include "ltbasetypes.h"  //contains definition of LTFLOAT

class AccurateTimer  
{
public:
	void CheckReset(LTFLOAT LithTime);
	LTFLOAT GetTime();
	AccurateTimer();
	virtual ~AccurateTimer();

private:
	void ResetTimeStart();
	LARGE_INTEGER	m_liStart;
	LARGE_INTEGER	m_liFrequency;
	LTFLOAT			m_ltfLastLithTime;
};

extern AccurateTimer g_pAccurateTimer;

#endif // !defined(AFX_ACCURATETIMER_H__83F795EC_A278_499B_BD11_73B17E05FF69__INCLUDED_)

AccurateTimer.cpp
Code:
// AccurateTimer.cpp: implementation of the AccurateTimer class.
//
//////////////////////////////////////////////////////////////////////

#include "AccurateTimer.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

AccurateTimer::AccurateTimer()
{
	//query the frequency for our calculations
	QueryPerformanceFrequency(&liFrequency);
	// Start time measurement
	::QueryPerformanceCounter(&liStart);
}

AccurateTimer::~AccurateTimer()
{
	//destructor code
}

LTFLOAT AccurateTimer::GetTime()
{
	LARGE_INTEGER liCurrent;

	// Query for time measurement
	QueryPerformanceCounter(&liCurrent);

	LONGLONG llTimeDiff = liCurrent.QuadPart - liStart.QuadPart;

	// To get duration in milliseconds
	return (LTFLOAT)llTimeDiff / (LTFLOAT)liFrequency.QuadPart;
}

void AccurateTimer::CheckReset(LTFLOAT LithTime)
{
	if(LithTime<LastLithTime)
	{
		ResetTimeStart();
		LastLithTime=0.0f;
	}
	else
		LastLithTime=LithTime;
}

void AccurateTimer::ResetTimeStart()
{
	//reset start time
	::QueryPerformanceCounter(&liStart);
}

AccurateTimer g_pAccurateTimer;


thanx in advance for saving my sanity

If somethings hard to do, its not worth doing - Homer Simpson
 
bugger...

scratch that.

forgot to add #include <windows.h>

(also noticed id changed some variable names [sadeyes])

If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top