Overview
Features
Download
Documentation
Community
Add-Ons & Services

VS2005 compile TryEnterCriticalSection identifier not found

Please post support and help requests here.

VS2005 compile TryEnterCriticalSection identifier not found

Postby kevin00000000ex » 10 Jan 2013, 16:42

I develop an app using POCO with vs2005 and meet two problems.
The first sample as follows:
Code: Select all
#include <windows.h>
#include "Poco/Path.h"
#include "Poco/File.h"
#include "Poco/Exception.h"
#include "Poco/Util/IniFileConfiguration.h"

int WinMain(...)
{
    //some code
    CreateProcess(...);
   //some code
}

when I compile the cpp, I meet a error "error C3861: 'TryEnterCriticalSection': identifier not found".But if I include the header files of POCO before the windows.h like
Code: Select all
#include "Poco/Path.h"
#include "Poco/File.h"
#include "Poco/Exception.h"
#include "Poco/Util/IniFileConfiguration.h"
#include <windows.h>

then the 'TryEnterCriticalSection' can be found. Why? I have not found any introduction about the order of including header file.


The second sample as follows:
The code is identical with the first sample except that the POCO header file are included before windows.h and I meet anther problem when compile it.
"error C3861: 'CreateProcess' : identifier not found" (But the 'CreateProcessA' is OK.)
And if I delete the '#include "Poco/Util/IniFileConfiguration.h"', compile successfully too.
So why the compiler can not find 'CreateProcess' if I include "Poco/Util/IniFileConfiguration.h" regardless of after or before window.h?
kevin00000000ex
 
Posts: 7
Joined: 26 Dec 2012, 02:14

Re: VS2005 compile TryEnterCriticalSection identifier not fo

Postby alex » 10 Jan 2013, 18:22

kevin00000000ex wrote:then the 'TryEnterCriticalSection' can be found. Why? I have not found any introduction about the order of including header file.
...
So why the compiler can not find 'CreateProcess' if I include "Poco/Util/IniFileConfiguration.h" regardless of after or before window.h?


Has to do with _WIN32_WINNT definition. Make sure it is defined early and properly.
alex
 
Posts: 1116
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: VS2005 compile TryEnterCriticalSection identifier not fo

Postby kevin00000000ex » 11 Jan 2013, 02:22

alex wrote:
kevin00000000ex wrote:then the 'TryEnterCriticalSection' can be found. Why? I have not found any introduction about the order of including header file.
...
So why the compiler can not find 'CreateProcess' if I include "Poco/Util/IniFileConfiguration.h" regardless of after or before window.h?


Has to do with _WIN32_WINNT definition. Make sure it is defined early and properly.


Thanks for your attention Alex.
I realize it too. So I import the header files of POCO before 'windows.h', and then the first problem is solved.
But the second problem can not be solved no matter what position I import the "Poco/Util/IniFileConfiguration.h".
And more strange is the "CreateProcessA" is OK. What should I do?
kevin00000000ex
 
Posts: 7
Joined: 26 Dec 2012, 02:14

Re: VS2005 compile TryEnterCriticalSection identifier not fo

Postby kevin00000000ex » 11 Jan 2013, 02:57

I know the reason of the second problem,because of "Poco/UnWindows.h".There are some #undef operation including 'CreateProcess'

By a way, how can I finish the topic?
kevin00000000ex
 
Posts: 7
Joined: 26 Dec 2012, 02:14

Re: VS2005 compile TryEnterCriticalSection identifier not fo

Postby alex » 11 Jan 2013, 03:37

kevin00000000ex wrote:And more strange is the "CreateProcessA" is OK. What should I do?

Call CreateProcessA. If you need to handle both narrow and wide, ifdef it. That's what we do - disarm the macros and deal with that ourselves. See this for an example.
alex
 
Posts: 1116
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: Silvos90 and 1 guest