-
October 28th, 2007, 08:37 AM
#1
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 :
Code:
#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
Code:
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
-
October 28th, 2007, 02:04 PM
#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 recommends that you don't handle the EXCEPTION_POSSIBLE_DEADLOCK exception in your code.
-
November 2nd, 2007, 04:49 PM
#3
Re: InitializeCriticalSectionAndSpinCount
Originally Posted by Arjay
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 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!
-
November 3rd, 2007, 01:18 PM
#4
Re: InitializeCriticalSectionAndSpinCount
Okay, did you declare the cs object and a pointer (with the pointer pointing to the address of the cs) or did you just declare a pointer?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|