【问题标题】:Metro UI/Store App, ARM and error C3861: 'Sleep': identifier not foundMetro UI/Store 应用程序、ARM 和错误 C3861:“睡眠”:找不到标识符
【发布时间】:2016-04-28 00:25:42
【问题描述】:

我在检测 Metro UI/Store 应用程序、ARM 应用程序和应包含的标头时遇到问题。

我有一个源文件需要<windows.h> 用于VOIDLPVOIDHANDLELPHANDE 和一些基本服务声明,如WaitForMultipleObjectsSleep。以下适用于常规桌面程序:

#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,我需要包含 &lt;synchapi.h&gt;。所以我根据 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


    【解决方案1】:
    // 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
    

    我需要强制包含&lt;sdkddkver.h&gt;,以便为WINVER_WIN32_WINNT 分配一个值。我也停止使用_WIN32_WINNT_WIN8

    #if (WINVER >= 0x0602) || (_WIN32_WINNT >= 0x0602)
    #include <synchapi.h>
    #endif
    

    【讨论】:

      猜你喜欢
      • 2013-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-31
      • 1970-01-01
      • 1970-01-01
      • 2013-04-23
      相关资源
      最近更新 更多