如何将gcc警告转储为结构化格式? [英] How do I dump gcc warnings into a structured format?
问题描述
由于并非所有警告标志都是有害的,汇编变得很嘈杂。
诸如未使用的变量,初始化列表中的遮蔽成员,缺少开关默认值等警告对于日志都很重要,但是在构建期间它们会造成太多混乱,并且很难发现重要的警告。
给定一个大型项目,可能会有成千上万的警告与构建语句混合在一起,而解析虽然后来变得繁重。在代码中维护编译器pragma和push / pop警告同样是不可取的。
如何以结构化格式转储编译器警告? >
是否为
XML,JSON,YAML,CSV有没有办法告诉编译器转储所有发出的警告?这样的格式可以让我更有效地查看警告,并按照类型,文件,金额等对它们进行排序。
- coala 项目试图让它所包装的工具产生相同的结构化输出格式(参见< a href =http://wordpress.schuirmann.eu/2016/02/coala-at-fosdem-2016/#comment-123 =nofollow> http://wordpress.schuirmann.eu/2016/02 / coala-at-fosdem-2016 /#comment-123 )。令人遗憾的是,似乎还没有一个熊来包装编译器。
- 在类似的说明中,爱立信已经构建了一个名为 CodeChecker ,可让您随时追踪项目的铿锵静态分析警告。
- 濒临死亡项目称为 firehose ,它封装了gcc和多个C静态分析工具的输出。 >
- 铿锵有
- fdiagnostics-format = msvc
,这可以使其输出稍微更加结构化。
在此期间可能会帮助你的东西是将这些编译器警告您使用 -Werror =
认为错误至关重要所以你注意到他们把这个建筑打破了警告声。
Like many, I build my project with the an abundance of warning flags.
Since not all warning flags are detrimental, the compilation becomes noisy.
Warnings such as "unused variables", "shadowing members in initialization lists", "missing switch defaults", are all important to log, but they create too much clutter during builds, and it is hard to spot the important warnings.
Given a large project, there can be thousands of warnings mixed in with build statements, and parsing though it afterwards becomes burdensome. It's equally undesirable to maintain compiler pragmas and push/pop warnings inside code.
How can I dump compiler warnings in a structured format?
Whether it be
XML, JSON, YAML, CSV, is there a way to tell the compiler to dump all emitted warnings? A format like this would allow me to view warnings more efficiently, and sort them by type, file, amount, etc.
- The coala project attempts to make the tools it wraps produce the same structured output formats (see http://wordpress.schuirmann.eu/2016/02/coala-at-fosdem-2016/#comment-123 ). Sadly there doesn't seem to be an already made "bear" to wrap a compiler.
- On a similar note to the above, Ericsson have built a tool called CodeChecker that lets you track a project's clang static analysis warnings over time.
- There is an moribund project called firehose that wrapped the output of gcc and several C static analysis tools.
- clang has
-fdiagnostics-format=msvc
which can make its output slightly more structured.
Something that might help you in the meantime is to turn those compiler warnings you deem critical into errors using -Werror=
so you notice them breaking the build above the noise of the warnings.
这篇关于如何将gcc警告转储为结构化格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!