I'm writing a Timer class in VS2013 using some Windows features but Visual Studio doesn't recognize them even including windows.h header.
Win32Timer.h
#pragma once
#include "Timer.h"
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#if !defined(NOMINMAX) && defined(_MSC_VER)
# define NOMINMAX
#endif
#include <windows.h>
class Win32Timer : public Timer {
public:
Win32Timer();
~Win32Timer();
void reset() override;
ulong getMilliseconds() override;
ulong getMillisecondsCPU() override;
ulong getMicroseconds() override;
ulong getMicrosecondsCPU() override;
protected:
ulong getTime() override;
private:
clock_t m_StartClock;
DWORD m_StartTick;
LONGLONG m_LastTime;
LARGE_INTEGER m_StartTime;
LARGE_INTEGER m_Frequency;
};
Timer.h (Prerequisites.h is just a bunch of forward declarations and STL headers)
#pragma once
#include "Prerequisites.h"
class Timer {
public:
Timer();
~Timer();
virtual void reset() = 0;
virtual ulong getMilliseconds() = 0;
virtual ulong getMillisecondsCPU() = 0;
virtual ulong getMicroseconds() = 0;
virtual ulong getMicrosecondsCPU() = 0;
protected:
virtual ulong getTime();
};
When I try to compile I get the following errors for each member variable that uses the windows' data types.
1>c:usersjeandocumentsvisual studio 2013projectsdracdracwin32timer.h(33): error C2146: syntax error : missing ';' before identifier 'm_LastTime'
1>c:usersjeandocumentsvisual studio 2013projectsdracdracwin32timer.h(33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
If I click to go to definition, VS takes me to the right place where the data type is defined but fails to recognize it in compile time. What could the problem be?
If I include <winnt.h> instead of <windows.h> the types are recognized but I get a fatal error C1189: #error : "No Target Architecture".
Aucun commentaire:
Enregistrer un commentaire