Skip to main content
GameDev.net gamedev.net
🔒 Locked

new MSVC++ Patch

Started by TheLameDuck Feb 23, 2003 at 11:05 AM 1 replies 800+ views
Original Post
TheLameDuck
TheLameDuck
I just downloaded the latest MSVC++ service patch, actually the last 4 of them(i''m a little slow), and found that now a very simple timer that i use isn''t working correctly. it always claims that 0 miliseconds have elapsed since checking it, even if i put a delay in front of it for many seconds. the problem goes away if i write to a flat txt file inside the getelapsedtime() function. I think it may deal with new optimizations with the new 4 service packs, does anyone know what the problem is, i think it may be running my program in it''s own thread, so how can i fix this? I''d appreciate any help you guys could give me.
Air
Air
First off, service packs are not accumulative. You need only download the latest one (SP5 last time I checked a couple months ago).

Anyways, it could very well be the optimizations as you think. To make sure, I''ll usually compile and run m program under a debug build and see if it still exhibits the same behavior. Are you using the method of updating a global variable as a timer tick counter? If so, you need to make sure that you prefix the tick counter variable delcaration with volatile . ie:

volatile int mytime;

That tells the compiler that the variable could be changed at any time outside the realm of the currently execulting code loops. In other words, it effectively disables register optimizations of variables. And to clarify: SP5 won''t do any sort of additional threading without your knowledge of it and a goodly amount of effort on your part to create and manage those threads.

- Air
TheLameDuck
TheLameDuck
thank you so much, volatile worked

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.