本文共 415 字,大约阅读时间需要 1 分钟。
原因:虽然包含了windows.h,但未定义_WIN32_WINNT。
因为在winbase.h (包含在windows.h中) 中, TryEnterCriticalSection只有定义了_WIN32_WINNT 且 _WIN32_WINNT>= 0x0400 时才会被定义。所以解决方法是在编译选项中加入 /D "_WIN32_WINNT=0x0500"。
附:_WIN32_WINNT 与 windows 版本的对应关系
_WIN32_WINNT | Windows 版本 |
0x0500 | Windows 2000 |
0x0501 | Windows XP |
0x0502 | Windows Server 2003 |
0x0600 | Windows Vista |
0x0601 | Windows 7 |
Reference:
1. 修改WINVER和_WIN32_WINNT:
2. TryEnterCriticalSection function:
转载地址:http://vxhai.baihongyu.com/