简体   繁体   English

条件变量函数未在此范围内声明

[英]Condition variable functions were not declared in this scope

Its the first time I'm using WINAPI and with functions like SleepConditionVariableCS , WakeConditionVariable , WaitForMultipleObjects and InitializeConditionVariable Eclipse IDE told me that they were not declared in this scope. 这是我第一次使用WINAPI并使用SleepConditionVariableCSWakeConditionVariableWaitForMultipleObjectsInitializeConditionVariable之类的功能 Eclipse IDE告诉我,它们不在此范围内声明。

All of them are supposedly included in the same lib windows.h so i dont know what's failings because other functions like ExitThread , ReleaseSemaphore and WaitForSingleObject are running without any problem. 据推测所有这些都包含在同一个lib windows.h中,所以我不知道出了什么问题,因为其他函数(如ExitThreadReleaseSemaphoreWaitForSingleObject)正在运行而没有任何问题。

It can be some problem with my c++ version? 我的C ++版本可能有问题吗? Or it exist any other library to include? 还是存在其他要包含的库?

Thanks 谢谢

The documentation for SleepConditionVariableCS (or any other WIndows API call) tells you the minimum supported client and server OS. SleepConditionVariableCS (或任何其他WIndows API调用)的文档告诉您所支持的最低客户端和服务器操作系统。 The API calls are conditionally declared, based on your target platform setting. 根据您的目标平台设置,有条件地声明API调用。

You can control your target platform by setting certain preprocessor macros (see Using the Windows Headers for information). 您可以通过设置某些预处理器宏来控制目标平台(有关信息,请参阅使用Windows标头 )。 In your case you need to add 您需要添加

#define WINVER 0x0600

before including Windows.h , to target Windows Vista and later. 在包含Windows.h之前,以Windows Vista和更高版本为目标。 It is common practice to define the preprocessor macro on the command line, to use a consistent environment across all compilation units. 通常的做法是在命令行上定义预处理器宏,以便在所有编译单元中使用一致的环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM