【发布时间】:2016-04-28 00:25:42
【问题描述】:
我在检测 Metro UI/Store 应用程序、ARM 应用程序和应包含的标头时遇到问题。
我有一个源文件需要<windows.h> 用于VOID、LPVOID、HANDLE、LPHANDE 和一些基本服务声明,如WaitForMultipleObjects 和Sleep。以下适用于常规桌面程序:
#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 Developer Prompt 并编译源文件时,结果是:
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''
...
根据 MSDN 上的 Sleep docs,对于 Windows 8、Windows Server 2012 和 Windows Phone 8.1,我需要包含 <synchapi.h>。所以我根据 MSDN 中的Operating System Version 将包含块更改为以下内容:
// 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 下编译,但在 Windows 7 上的 Visual Studio 2012 下编译失败:
1> wait.cpp
1> c:\users\...\wait.h(26): fatal error C1083: Cannot open include file: 'synchapi.h': No such file or directory
我做错了什么,我该如何解决?
【问题讨论】:
标签: windows visual-studio arm