【发布时间】:2012-04-10 02:08:52
【问题描述】:
所以当谈到 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
真正奇怪的是,我之前对不同目录中的不同程序使用了完全相同的包含,并且一切(仍然)编译得很好。如果我将它们全部注释掉,并且使用包含的代码,它编译得很好;如果我使用包含注释的代码保留代码,但即使在其中一个包含中添加注释,我也会再次收到所有错误。
我的环境有什么问题导致它在这个目录中失败吗?
【问题讨论】:
-
/usr/include/root/?是什么创建了那个目录? -
我安装了root数据分析软件
-
您确实需要发布代码,以便我们识别任何潜在的错误。但听起来您在代码中的某处存在语法错误,导致嵌入式链接错误。检查你的代码是否有语法错误,也许把它贴在这里以便我们查看。
-
语法错误可能在标头中。无论哪种方式,您都不应该使用答案来发表评论。但我知道你可能没有写 cmets 的名声。
-
我没有写任何头文件。据我所知,我的代码中没有错误,因为我可以注释掉使用包含和包含本身的函数,并且一切都编译得很好。只有当我在包含中取消注释时才会发生这种情况
标签: linux header compiler-errors g++