私はVisual Studioでプロジェクトを作成します。このプロジェクトでは私は2つのメンバを持つCSimApplianceDlgというクラスを構築する:C++クラス静的メンバー関数呼び出しエラー
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);
私はUINT CSimApplianceDlgで
m_Port.WriteToPort(m_SendData,len);
と呼ばれる:: RecvDataFrame(LPVOID pParam)。ただ、呼び出しのラインで、プロジェクトをビルドしながら、しかし、私が得た
1> E:\ mysourcecode \ smarthome \ simappliance \ simappliance \ simappliancedlg.cpp(557) :エラーC2228は: "の左.WriteToPortはクラス/構造体/共用体を持つ必要があります
1:e:\ mysourcecode \ smarthome \ simappliance \ simappliance \ simappliancedlg.cpp(557):エラーC2597:非staticメンバ 'CSimApplianceDlg :: m_SendData'への参照が不正です
1> e:\ mysourcecode \ smarthome \ simappliance \ simappliance \ simappliancedlg.cpp(557):エラーC2597:非静的メンバー 'CSimApplianceDlg :: len'への不正な参照
これらのエラーをどうすれば処理できますか?そして はLPCTSTR
に慣れていないので、WriteToPort
が呼び出されます。
これらのエラーが発生したコードを表示するのを忘れました。 –
'CSerialPort'クラスの*インスタンス*の作成に失敗した可能性があります。マイケルが言ったように、実際のコードを見ることができなければ、わからない。質問を[mcve]で更新してください。 –
は "m_Port.WriteToPort(m_SendData、len);"を呼び出す際にリンナがエラーになります。 – pellyhawk