如何设置 Eclipse gcc 编译器忽略特定错误或从错误更改为警告
我需要构建一个由许多 C 源文件和头文件组成的项目。该项目在 xcode 中编译时带有警告(这很好),但是当我尝试在 Windows XP 上的 Eclipse 中使用 GNU gcc C 编译器来编译它时,我收到许多“重新声明”和“嵌套重新定义”错误。这些错误都引用了几个不同头文件中枚举器的 typedef。
这些头文件中的每一个在整个文件周围都有适当的 #ifndef/#define/#endif 标记,但它们 typedef 相同的枚举器(将 typedef 复制/粘贴到多个头中),这样一个头文件将 #include 多个其他头文件其中具有相同名称的相同枚举器 typedef。
我被告知这在 xcode 中编译时会出现警告,并且不允许我修改现有代码。
由于它在 xcode 中编译时带有警告,我试图找到一种方法让 Eclipse 忽略这些错误或将它们更改为警告进行编译,但没有成功。编译器使用第一个还是最后一个定义/声明并不重要。它们是相同的重新定义/重新声明。
有办法做到这一点吗?
编辑:使用错误标志 -Wall 进行编译
I need to build a project consisting of many C source and header files. The project compiles in xcode with warnings (which is fine) but when I try to compile it using the GNU gcc C compiler in Eclipse on Windows XP, I get many "redeclaration of" and "nested redefinition of" errors. These errors all reference typedefs of enumerators in several different header files.
Each of these header files have appropriate #ifndef/#define/#endif tags around the entire file, but they typedef the same enumerators (think copy/paste typedefs into multiple headers) such that one header file will #include several other header files each of which have the same enumerator typedef with the same name.
I'm told this compiles with warnings in xcode and I am not allowed to modify the existing code.
As it compiles with warnings in xcode, I was trying to find a way to have Eclipse ignore those errors or change them to warnings to compile but have been unsuccessful. It doesn't matter if the compiler uses the first or the last definition/declaration. They are identical redefinitions/redeclarations.
Is there a way to do this?
Edit: compiling with error flag -Wall
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的编译器不太可能让您将错误更改为警告。不过,大多数人会让你反其道而行之。您是否将
-Werror
传递给 windows/eclipse 系统中的编译器?听起来你的一些包含守卫不起作用。如果您向我们提供更多详细信息,我们也许可以为您提供帮助。Your compiler is unlikely to let you change an error into a warning. Most will let you go the other way around, though. Are you passing
-Werror
to the compiler in your windows/eclipse system? It sounds like some of your include guards aren't working. If you give us some more detail we might be able to help you out.