highlight and filter (gcc) compiler messages

后端 未结 8 1527
情话喂你
情话喂你 2021-01-06 09:11

i\'m currently refactoring a C-project, throwing about 1000 warnings at me. is there a way to highlight and filter these warnings. (eg make all index warnings red, unused bl

8条回答
  •  一个人的身影
    2021-01-06 09:23

    This answer is more about the general approach to reworking old C code.

    Large volumes of warnings usually are repetitions of the same small group of warnings because of some errors in header files that are included all over the place by other source code files.

    If you're refactoring an old C project, quite often most warning come down to various things such as old K'n'R function dec's, previously allowed casts now being highlighted with a warning, using deprecated functions, etc.

    Assuming you're using (g)make to build the project, I'd run the compile using the following command:

    gmake 2>&1 | tee results
    

    Then you can have a look at the results file and see what are the most popular warnings you're getting. Start with eliminating all existing warnings before getting on to any refactoring of the code base.

    Running the make from within vim gives you lots of possibilities to couple the error and warning messages with the source files.

提交回复
热议问题