为什么没有定义SRWLock ?

Why is SRWLock undefined?

本文关键字:SRWLock 定义 为什么      更新时间:2023-10-16

我正试图使用SRWLock与c++项目Visual Studio 2012 (Windows 7)仅针对32位Windows, SRWLock在我的情况下比CriticalSections更好。正如我所搜索的,我应该包括WinBase.h并使用std命名空间。但是SRWLock仍然没有定义。在谷歌上找不到有用的东西。我错过了什么?我很感激任何线索。代码:

#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

类型错误:应该是SRWLOCK而不是SRWLOCK。你需要

#include <windows.h>