Amit jha
Amit jha

Reputation: 7

How to use try catch in visual studio c++?

#include <windows.h>

int csOpsPrintDataInitialized = 0;

void ObtainOpsPrintDataCritSect()
{
    CreateCriticalSectionAsNeccessary();

    EnterCriticalSection(&csOpsPrintData);
} // Hp fortify in visual studio 2013 reporting issue: Exception handling.

but on using try catch it is still reporting same issue.

void ObtainOpsPrintDataCritSect_sol()]
{
    try
    {
        EnterCriticalSection(&csOpsPrintData);
    }
    catch(char *msg)
    {
    }
}

Hp fortify recommendation: This problem can be avoided in two ways:

Upvotes: 0

Views: 694

Answers (1)

dkg
dkg

Reputation: 1775

I think it is a false positive you should ignore the recommendation in fortify because the documentation on EnterCriticalSection on msdn states :

Do not handle a possible deadlock exception; instead, debug the application.

Upvotes: 1

Related Questions