0

だから私はg ++とLinuxに関しては初心者のようなものですが、私が書いたC ++プログラムをコンパイルしようとしています.何らかの理由でg ++は私のインクルードに問題があり、文字通り何千行ものC++ インクルード ファイル (stdio.h、string.h など) からのエラー。それらのいくつかを以下に貼り付けました。

    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

本当に奇妙なのは、以前にまったく同じインクルードを別のディレクトリの別のプログラムに使用したことがあり、すべてが (まだ) 正常にコンパイルされることです。それらすべてとインクルードを使用するコードをコメントアウトすると、正常にコンパイルされます。コメントアウトされたインクルードを使用してコードを保持しても、インクルードの 1 つでもコメントすると、すべてのエラーが再び発生します。

この1つのディレクトリで失敗する環境に何か問題がありますか?

4

1 に答える 1

1

最も可能性の高い原因:の前に別のヘッダーを#includeingしており、その別のヘッダーにセミコロンがありません。TH1F.h

// some other header
struct Foo {
....
}
 ^ missing ;
于 2012-04-10T03:28:55.283 に答える