我用视觉工作室写了一个项目。在项目中,我构建了一个名为 CSimApplianceDlg 的类,它有两个成员:
static UINT RecvDataFrame(LPVOID pParam)
和CSerialPort m_Port
class CSimApplianceDlg : public CDialog
{
// Construction
public:
CSimApplianceDlg(CWnd* pParent = NULL); // standard constructor
// Implementation
protected:
HICON m_hIcon;
// Added for Serial Port operation
static UINT RecvDataFrame(LPVOID pParam); // Process received data
......
private:
......
unsigned char m_SendData[MAX_LEN]; // Data to be sent
int len; // the length of data to be sent
public:
CSerialPort m_Port; // CSerialPort Object
......
CSerialPort
有一个公共成员函数WriteToPort
通过串口发送数据。
public:
void WriteToPort(char* string);
void WriteToPort(char* string,int n);
void WriteToPort(LPCTSTR string);
void WriteToPort(LPCTSTR string,int n);
我打了电话
m_Port.WriteToPort(m_SendData,len);
在 UINT CSimApplianceDlg::RecvDataFrame(LPVOID pParam) 中。但是,在构建项目时,就在调用的那一行,我得到了
1>e:\mysourcecode\smarthome\simappliance\simappliance\simappliancedlg.cpp(557):错误 C2228:'.WriteToPort' 左侧必须有类/结构/联合
1>e:\mysourcecode\smarthome\simappliance\simappliance\simappliancedlg .cpp(557) : 错误 C2597: 非法引用非静态成员 'CSimApplianceDlg::m_SendData'
1>e:\mysourcecode\smarthome\simappliance\simappliance\simappliancedlg.cpp(557) : 错误 C2597: 非法引用非静态成员 'CSimApplianceDlg::len'
我该如何处理这些错误?并且WriteToPort
被称为,因为我不熟悉LPCTSTR
。