代码改变世界

vs2003编译中的错误:即使使用参数相关的查找,也未找到标识符

2012-04-11 15:48  上帝之骰  阅读(837)  评论(0编辑  收藏  举报

  在vs2003下使用内核对象进行同步,使用event和semaphore对象均没有问题,但是使用WaitableTimer时却提示:

  error C3861:   “CreateWaitableTimer”:   即使使用参数相关的查找,也未找到标识符 

  在工程中已经包含了 windows.h,而且msdn中CreateWaitableTimer函数Requirement为

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

WinBase.h (include Windows.h)

  尝试明确添加winbase.h,仍然无效。

  后来在这里找到了答案http://topic.csdn.net/t/20031110/14/2445621.html

  在#include   <windows.h> 前面添上:#define   _WIN32_WINNT   0x0501

  试了一下,果然可以了。 

  但是奇怪的是,0x0501应该是XP的版本号,如果是因为平台版本问题造成的错误,那么CreateEvent()函数的调用要求也是

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

WinBase.h (include Windows.h)

  为何Event就可以正常使用呢?