Access violation

Posted on 2003-11-02
Last Modified: 2012-05-04
I have a global CRITICAL_SECTION object, but when I try to use EnterCriticalSection() with it, I get an access violation.

CRITICAL_SECTION g_criticalSection;

//Then later on in a global function I have
EnterCriticalSection(&g_criticalSection);  // Access violation here

What could be the problem?
Question by:lwinkenb
  • 2
LVL 86

Accepted Solution

jkr earned 500 total points
ID: 9666663
Have you used

InitializeCriticalSection (  g_criticalSection);

before using it? If not, this would explain the problem...

Author Comment

ID: 9666683
argh, I knew it was something simple.
Thanks jkr.
LVL 86

Expert Comment

ID: 9666693
You're most welcome :o)

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question