Using TryEnterCriticalSection() is not a member of '`global namespace''

Using TryEnterCriticalSection() generates this error C2065 is not a member of '`global namespace''

However using  InitializeCriticalSection() or LeaveCriticalSection() does not generate any errors.

All functions are declared in Winbase.h  

Why does one genrate the error and not the others ?

How to fix it ?
hansw77041Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AxterCommented:
Hi hansw77041,
> >TryEnterCriticalSection

Do you have include Windows.h ???

David Maisonave :-)
Cheers!
0
AxterCommented:
Are you sure you have include Winbase.h  before using TryEnterCriticalSection?
0
hansw77041Author Commented:
Axter:

Yes #include <winbase.h> is delcared in stdafx.h .
Interesting when I type ::TryE... The IDE pops up a selection dialog and sure enough there it is. !
So at that point ::TryEnterCriticalSection() is known !

This is crazy why does InitializeCriticalSection() or LeaveCriticalSection()  work without problems...
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

hansw77041Author Commented:
From stdafx.h

#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h>            // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>                  // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <Windows.h>
#include <Winbase.h>

0
hansw77041Author Commented:
Turns out Windows.h should NOT be included...

#include <Windows.h>
// fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

Anyway problem remains the same !
0
jkrCommented:
Remove

#define VC_EXTRALEAN          // Exclude rarely-used stuff from Windows headers

from your StdAfx.h
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jkrCommented:
BTW, also make sure to either

#define _WIN32_WINNT  0x0400

or set _WIN32_WINNT=0x0400

in your project settings.
0
hansw77041Author Commented:
That fixed it... thanks jkr.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.