views:

83

answers:

1

The specific problem is, the support of condition variable on Windows begins from Vista, for early version of Windows (Windows XP), I have a emulated condition variable code sort of solved the problem. However, I'd like to have the ability to call native condition variable API when the system supported and fallback to my version only on XP and earlier version. I tried to detect windows version with GetVersionInfo API, but it still gives me error on start time (cannot find API entry of InitializeConditionVariable sort of).

I am not familiar with Windows programming, how do you solve the gentle fallback problem nicely?

+5  A: 

if you want to call a function that may or may not exist depending on platform version then use dynamic loading

LoadLibrary and GetProcAddress

These will tell you if the entry point exists and then let you call it if it does

pm100
You need to use the pointer returned by GetProcAddress to call the function, if you leave the regular function call in your program you'll still get the error.
Mark Ransom
yes - i kind of left the details to the OP (and Google). I am sure he will work the it out
pm100
Yes, it works form me. Thanks.
liuliu
The OP may figure it out, but it's best to be explicit for future explorers.
Mark Ransom