2010-01-20 29 views
0

我已經包含了QMutex頭文件並使用它,如下所示。但我得到以下錯誤:QMutex爲何未知?

error C2146: syntax error : missing > ';' before identifier > '_RecorderParamsMutex'

error C4430: missing type specifier - int assumed. > Note: C++ does not support default-int

error C4430: missing type specifier -> int assumed. Note: C++ does not > support default-int

#ifndef RECORDERinterface_h 
    #define RECORDERinterface_h 
    #include "qstring.h" 
    #include "ccc.h" 
    #include "ddd.h" 
    #include <qmutex.h> 
    #include "eee.h" 

using namespace Common; //for aaaaa 

class RecorderInterface{ 
    //the implemented recorders are my friends, the may access all my private stuff :) 
    friend class A; 
    friend class B; 

public: 
    RecorderInterface();  
    bool   setParam(RecorderPrintParam *up); 


private: 
    QMutex   _RecorderParamsMutex; 
}; 

#endif 
+2

不回答你的問題,但像_RecorderParamsMutex這樣的名字(以下劃線和大寫字母開頭的名字)保留給C++實現 - 你不能在你自己的代碼中創建這樣的名字。 – 2010-01-20 12:47:07

+0

好的謝謝,你有一個鏈接到該標準?所以我可以進一步看看這個命名標準。 – Christoferw

+0

該標準不在線提供 - 您必須爲此付費。有各種各樣的草稿敲門雖然。 – 2010-01-20 12:49:39

回答

3

看着header file,類聲明被#ifdef封裝。試着這樣說:

#define QT_THREAD_SUPPORT 
#include <qmutex.h> 

這大概應該是一個項目級的#define,以便其他線程定義可用。

0

缺少的命名空間? 我對QMutex並不熟悉,但是如果它附帶一些庫,它應該用庫的名稱空間來定義。除非它是「共同的」。

2

您使用的是哪個版本的Qt?從您的標題樣式看起來像Qt3

「早期版本的Qt提供了一個選項來構建沒有線程支持的庫。從Qt 4.0開始,線程始終處於啓用狀態。」 [source]

你確定你有線程支持內置到庫中嗎?

+0

是的,我正在使用QT 3.3 – Christoferw