为什么SRWLock未定义?

时间:2016-09-12 05:57:11

标签: c++ windows visual-studio-2012

我试图将SRWLock用于仅针对32位Windows的C ++项目Visual Studio 2012(Windows 7),而SRWLock在我的情况下比CriticalSections更好。 在我搜索过的时候,我应该包含WinBase.h并使用std命名空间。但SRWLock仍未定义。无法在Google上找到任何有用的内容。我错过了什么?我很欣赏任何线索。 代码:

#include <cstdlib>
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <windows.h>
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <conio.h>
#include <WinBase.h>
using namespace std;
SRWLock gLock; // here is the problem

1 个答案:

答案 0 :(得分:1)

错误的地方:应该是SRWLOCK而不是SRWLock。 你需要

#include <windows.h>