views:

63

answers:

2

I am running producer consumer problem( using windows thread ).It compiling successfully but on running it showing following error

The procedure entry point InitializeConditionVariable could not located in the dynamic library Kernel32.dll.

can u tell what would be reason

+1  A: 

That's an API function that is only available in Vista and up. I would guess that you are running this code on XP.

To avoid accidentally using API functions that are only available in later versions of Windows, you'll want to define the _WIN32_WINNT macro:

#define _WIN32_WINNT 0x502   // Designed to run on Windows XP SP2 and up
#include <windows.h>

If you don't set it then it typically defaults to 0x600 on later versions of the Windows SDK, selecting Vista as the target operating system. Btw, you'll probably have to give up on condition variables. There isn't enough detail in your question to offer a suitable replacement. Code that uses mutexes instead shouldn't be hard to find.

Hans Passant
+1  A: 

InitializeConditionVariable and the related condition-variable APIs are only available on Windows Vista onwards. You could use Boost.Thread to provide a condition variable implementation which works on Windows XP. I wrote an article on my blog about how to use that for a producer/consumer queue.

Anthony Williams