为什么我不能使用LPCRITICAL_SECTION和CRITICAL_SECTION

时间:2012-09-07 00:01:07

标签: c++

我正在开发一个共享项目。 我有一些标识符错误,VS C ++ 2005不知道CRITICAL_SECTION和LPCRITICAL_SECTION。

LPCRITICAL_SECTION GetReadCS() { return &m_ReadCS; }
LPCRITICAL_SECTION GetWriteCS() { return &m_WriteCS; }

CRITICAL_SECTION    m_ReadCS;
CRITICAL_SECTION    m_WriteCS;

并出现了一些错误

warning C4183: 'GetReadCS': missing return type; assumed to be a member function returning 'int'
warning C4183: 'GetWriteCS': missing return type; assumed to be a member function returning 'int'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2146: syntax error : missing ';' before identifier 'm_WriteCS'

为什么LPCRITICAL_SECTION和CRITICAL_SECTION未定义?我怎样才能让C ++知道它?

1 个答案:

答案 0 :(得分:5)

您是否包含了windows.h?

#include <windows.h>