Metro UI/Store应用程序,ARM和错误C3861:'Sleep':标识符未找到
问题描述:
我在检测Metro UI/Store应用程序,ARM应用程序和应包含的标题时遇到问题。Metro UI/Store应用程序,ARM和错误C3861:'Sleep':标识符未找到
我有对VOID
,LPVOID
,HANDLE
,LPHANDE
和一些基本的服务声明像WaitForMultipleObjects
和Sleep
需要<windows.h>
源文件。
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
# define MYLIB_WIN32_AVAILABLE
#endif
#if defined(MYLIB_WIN32_AVAILABLE)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
当我打开VS2012 ARM开发者提示并编译源文件,它会导致:对于一个普通的桌面程序中的以下工作
cl.exe /nologo /D_MBCS /Zi /TP /EHsc /MT /DWINAPI_FAMILY=WINAPI_FAMILY_APP /c wait.cpp
wait.cpp
wait.cpp(140) : error C3861: 'Sleep': identifier not found
wait.cpp(145) : error C3861: 'PulseEvent': identifier not found
wait.cpp(149) : error C2039: 'WaitForMultipleObjects' : is not a member of '`global namespace''
...
按照Sleep
docs MSDN上,我需要包括用于Windows 8,Windows Server 2012和Windows Phone 8.1的<synchapi.h>
。所以我改变了包括块以下基于Operating System Version从MSDN:
// Windows 8, Windows Server 2012, and Windows Phone 8.1 need <synchapi.h>
#if (WINVER >= _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#include <synchapi.h>
#endif
然后它编译ARM下,但结果在Visual Studio 2012下破编译在Windows 7:
1> wait.cpp
1> c:\users\...\wait.h(26): fatal error C1083: Cannot open include file: 'synchapi.h': No such file or directory
什么时我做错了,我该如何解决?
答
// Windows 8, Windows Server 2012, and Windows Phone 8.1 need <synchapi.h> #if (WINVER >= _WIN32_WINNT_WIN8) || (_WIN32_WINNT >= _WIN32_WINNT_WIN8) #include <synchapi.h> #endif
我需要迫使包括<sdkddkver.h>
使WINVER
和_WIN32_WINNT
被分配一个值。我也停止使用_WIN32_WINNT_WIN8
:
#if (WINVER >= 0x0602) || (_WIN32_WINNT >= 0x0602)
#include <synchapi.h>
#endif