所以当涉及到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
真正奇怪的是,我之前使用了完全相同的包含在不同目录中的不同程序,并且所有(仍然)编译得很好。如果我全部评论它们,以及使用包含的代码,它编译得很好;如果我使用包含注释的代码保留代码,但即使其中一个包含注释我也会再次收到所有错误。
我的环境是否有问题导致它在这个目录中失败?
答案 0 :(得分:2)
最可能的原因:您#include
之前TH1F.h
另一个标头,而在另一个标头中,您有一个缺少的分号,例如
// some other header
struct Foo {
....
}
^ missing ;