犯错误 - gcc 编译器警告是否会阻止 C 文件被编译成目标文件?
我正在尝试为我的 Linux 机器编译无线网卡驱动程序,但在使用 Make 命令时遇到了问题。在编译过程中,我通常会在某些正在编译的 C 文件上看到警告;尽管有警告,这些文件仍然能够编译为目标文件。
然而,当Make进程到达一个名为rtmp_wext.c的文件时,编译器会生成大量警告,然后整个Make进程停止并返回错误1的退出状态,即make:*** [rtmp_wext.o]错误1
。通常我会看到 C 文件出现错误,导致编译停止。这是第一次出现编译器警告阻止文件转换为目标文件的情况;这是可能的还是其他原因导致编译失败?
I'm trying to compile a wireless network card driver for my Linux box and I ran into a problem with the Make command. During the compilation process I normally see warnings on some of the C files that being are compiled; despite the warnings these files were still able to be compiled to an object file.
When the Make process comes to a file called rtmp_wext.c however, the compiler generates a large number of warnings and then the whole Make process stops and returns an exit status of error 1, i.e. make: *** [rtmp_wext.o] Error 1
. Usually I see an error with the C file for compilation to halt. This is the first time where it seems compiler warnings are preventing the file from being turned into an object file; is this possible or is something else the cause for the unsuccessful compilation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 gcc 传递了
-Werror
选项,它将;它会导致警告被视为错误,但它们也会被重新标记为“错误”而不是“警告”,所以如果您看到“警告”,那就不是它了。可能是其他命令 make 正在运行;您可以尝试以详细模式运行它或仅检查 Makefile 以查看它正在执行哪些命令If gcc is being passed the
-Werror
option it will; it causes warnings to be treated as errors, but they'll also be relabeled "error" instead of "warning", so if you're seeing "warning" that's not it. It's probably some other command make is running; you can try things like running it in verbose mode or just checking the Makefile to see what commands it's executing您可以通过在命令开头(制表符之后)放置“-”来告诉 Make 忽略错误。如果这是您自己的代码,我建议您不要忽略症状,但我猜您不想调试此代码。
你说你可以编译 rtmp_wext.o 并带有警告森林。我同意德罗伯特的评论;那里很可能有错误。如果存在,则不能保证 rtmp_wext.o 能够真正工作,无论它是否工作,您都应该找到错误消息并告诉编写驱动程序的人。
You can tell Make to ignore the error by putting a '-' at the beginning of the command (after the tab). If this were your own code I'd advise you not to ignore a symptom, but I'm guessing you don't want to debug this code.
You say that you can compile rtmp_wext.o with a forest of warnings. I agree with derobert's comment; there may well be an error in there. If there is then there's no guarantee that rtmp_wext.o will actually work, and whether it works or not you should find the error message and tell whoever wrote the driver.