2012-04-10 91 views
0

所以我是一種新手,當涉及到g ++和linux,但我想編譯一個我寫的C++程序,無論出於何種原因g ++有問題我的包括,我從字面上從C++包含文件(如stdio.h,string.h等)幾千行錯誤。我粘貼以下幾個:從C++頭文件奇怪的g ++編譯器錯誤

In file included from /usr/include/stdio.h:75, 
      from /usr/include/root/Rtypes.h:33, 
      from /usr/include/root/TObject.h:31, 
      from /usr/include/root/TNamed.h:26, 
      from /usr/include/root/TAxis.h:25, 
      from /usr/include/root/TH1.h:25, 
      from /usr/include/root/TH1F.h:25, 
      from torusMC.cpp:10: 
    /usr/include/libio.h: In function ‘int _IO_feof(_IO_FILE*)’: 
    /usr/include/libio.h:462: error: expected primary-expression before ‘,’ token 
    /usr/include/libio.h:462: error: ‘printf’ was not declared in this scope 
    /usr/include/libio.h:462: error: ‘exit’ was not declared in this scope 
    /usr/include/libio.h: In function ‘int _IO_ferror(_IO_FILE*)’: 
    /usr/include/libio.h:463: error: expected primary-expression before ‘,’ token 
    /usr/include/libio.h:463: error: ‘printf’ was not declared in this scope 
    /usr/include/libio.h:463: error: ‘exit’ was not declared in this scope 

什麼是真正奇怪的是,我已經使用了完全相同的包括之前不同的程序在不同的目錄和一切(仍然)編譯就好了。如果我將它們全部發表出來,並且使用包含的代碼,那麼它編譯得很好;如果我使用包含註釋的代碼保留代碼,但即使在其中一個包含註釋中,我也會再次獲得所有錯誤。

我的環境有什麼問題,導致它在這個目錄中失敗嗎?

+0

'/ usr/include/root /'?什麼創建了該目錄? – sarnold 2012-04-10 02:10:37

+0

我安裝了根數據分析軟件 – user1042305 2012-04-10 02:11:31

+0

您確實需要發佈代碼,以便我們可以識別任何潛在的錯誤。但它聽起來像你在代碼中的某處引起嵌入鏈接錯誤的語法錯誤。檢查你的代碼是否有語法錯誤,也許在這裏發佈,以便我們可以查看它。 – 2012-04-10 02:13:24

回答

2

最可能的原因:你#include荷蘭國際集團另一頭的TH1F.h之前,並且在其他的頭,你有失蹤分號,例如

// some other header 
struct Foo { 
.... 
} 
^ missing ;