2012-06-15 62 views
0

我正在構建包含cuda代碼的cmake項目。我無法編譯包含幾個h文件的cuda文件之一。這是編譯器錯誤我收到isspace宏與locale_facets.h中的isspace函數衝突

In file included from /usr/include/c++/4.4/bits/basic_ios.h:39, 
       from /usr/include/c++/4.4/ios:45, 
       from /usr/include/c++/4.4/ostream:40, 
       from /usr/include/c++/4.4/iostream:40, 
       from /home/pfeifs/Developement/Deform/LinuxDeform/LibDeform/Deform/cutil_comfunc.h:20, 
       from /home/pfeifs/Developement/Deform/LinuxDeform/LibDeform/Deform/VectorMathDef.h:22, 
       from /home/pfeifs/Developement/Deform/LinuxDeform/LibDeform/src/Deform/VectorMath.cu:15: 
/usr/include/c++/4.4/bits/locale_facets.h:2521:44: error: macro "isspace" passed 2 arguments, but takes just 1 

isspace()被定義爲需要在<ctype.h>一個參數的宏和聲明爲locale_facets.h一個模板函數。 (這些都是標準文件。)但是,在locale_facets.h開頭,包含<cctype>,並且未聲明宏。

任何幫助或深入瞭解這個問題,非常感謝。

+0

嘗試對'cutil_comfunc.h'文件中的#include文件順序進行重新排序,以使C++包含在C includes之前。如果沒有別的話, – jxh

回答

5

請勿混用和匹配C和C++標頭。

使用#include <locale>來拉入帶有兩個參數的std::isspace模板。使用#include <cctype>作爲包含ctype.h的C++安全包,不會與STL發生衝突。

如果你正在編寫一個C程序,不想或不需要C++,那麼應該沒有問題,包括ctype.h和使用isspace函數只有一個參數。

+0

第一句+1。我假設其餘的都是對的,但即使不是這樣,第一句話也是問題的核心。 –

+0

在我需要包含的另一個隨機庫的包含路徑中,實際上還有一個額外的ctype.h文件,它明顯早於include路徑,而不是我要包含的標準ctype庫。我能夠解決這個問題,一切正常。 – Scottfivefour

+1

完美!也沒有正確的方法,但我發現我有更少的問題,如果我的包括順序是這樣的:C++,第三方庫,我的庫,本地頭 – AJG85