I have a compilation problem that I just can't explain in a c++ program on Visual Studio 2012. The error appears at several places in the program, here is an example:
#ifndef __WINMUTEX_H__
# define __WINMUTEX_H__
# ifdef _WIN32
# include <windows.h>
namespace Thread
{
class WinMutex
{
public:
WinMutex();
~WinMutex();
void lock();
void unlock();
bool trylock();
private:
CRITICAL_SECTION _mutex;
};
typedef WinMutex Mutex;
}
# endif
#endif
The compiler gives me an error (C2146). Basically the compiler doesn't seem to find the CRITICAL_SECTION identifier, neither does the Intellisense. As I said, this error occurs in several parts of the program and not just for CRITICAL_SECTION but also for HANDLE and even DWORD.
I tried replacing the windows.h include with the windows 8 equivalent (synchapi.h) but then I still get the error with the addition of the "No target architecture" error.
What's weird is that this code works when I used it in a project on visual studio 2010 on Windows 7.
Anyone knows why this is happening?
Thanks
If your project is a Windows Store app project, some parts of the Win32 API are not available, apparently including CRITICAL_SECTION and related. You'll have to use C++/CX equivalents, see: http://msdn.microsoft.com/en-us/library/windows/apps/hh771042.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.