Reputation: 54103
I'm trying to make a timer in c++. I'm new to c++. I found this code snippet
UINT_PTR SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc);
I put it in my global variables and it tells me
Error 1 error C2373: 'SetTimer' : redefinition; different type modifiers
I'm not sure what this means. Is there a more proper way to define a timer?
I'm not using mfc / afx
Thanks
Upvotes: 0
Views: 1323
Reputation: 76500
You should call it like this:
void CALLBACK TimerProc(
HWND hwnd,
UINT uMsg,
UINT idEvent,
DWORD dwTime
)
{
//do something
}
SetTimer(NULL, NULL, 1000, TimerProc);
This would set a timer for 1 second and will call TimerProc when it expires. Read TimerProc MSDN here: http://msdn.microsoft.com/en-us/library/ms644907%28VS.85%29.aspx
Upvotes: 3
Reputation: 42577
That's not a function call -- that's a function declaration, which you are probably already #including from somewhere. What you need is the actual SetTimer call from your code.
Can you post your code where you're trying to set up the timer, and the function you want it to call when it triggers?
Upvotes: 1