InitializeCriticalSectionAndSpinCount
Hi, all,
I'm new to Windows programming, though I've been doing C/C++ for about 8 years. I'm trying to use a CRITICAL_SECTION without any luck. I was trying to follow the example at
http://msdn2.microsoft.com/en-us/library/ms683476.aspx
I'm just trying to understand how the function calls work right now. I have :
#include <Windows.h>
// ...
res = InitializeCriticalSectionAndSpinCount(_cs, 0x80000400);
// ...
__try
{
EnterCriticalSection(_cs);
}
__except (EXCEPTION_POSSIBLE_DEADLOCK)
{
std::cout << "Deadlock?" << std::endl;
exit(0);
}
However, I'm getting
error C3861: 'InitializeCriticalSectionAndSpinCount': identifier not found, even with argument-dependent lookup
error C2065: 'EXCEPTION_POSSIBLE_DEADLOCK' : undeclared identifier
What am I doing wrong? I'm using VisualStudio .NET 2003 on WinXP.
Thanks!
Don
[1041 byte] By [
mysterd429] at [2007-11-20 11:43:23]

# 1 Re: InitializeCriticalSectionAndSpinCount
include <process.h>.
Also you need to pass in the address to the critical section in these functions (i.e. &_cs).
Looks like the later msdn documentation (http://msdn2.microsoft.com/en-us/library/ms682608.aspx) recommends that you don't handle the EXCEPTION_POSSIBLE_DEADLOCK exception in your code.
Arjay at 2007-11-10 22:24:06 >

# 2 Re: InitializeCriticalSectionAndSpinCount
include <process.h>.
Also you need to pass in the address to the critical section in these functions (i.e. &_cs).
Looks like the later msdn documentation (http://msdn2.microsoft.com/en-us/library/ms682608.aspx) recommends that you don't handle the EXCEPTION_POSSIBLE_DEADLOCK exception in your code.
Thanks for the reply! _cs is a pointer in my example. With the deadlock exception, I was just trying to see if I had the syntax for that try/catch thing right.
Cheers!