How to enforce C89-style variable declarations in gcc?

前端 未结 3 1016
执笔经年
执笔经年 2021-02-07 23:55

I work on a code base which is mostly C with a little C++, and is mostly built with gcc but occasionally it needs to be built with MSVC. Microsoft\'s C compiler is still pretty

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-08 00:39

    You're after the -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations and -Wdeclaration-after-statement options, as described on the gcc warnings info page. Note that these can cause a lot of noise from issues in system header files, and they're only warnings so you've got to have a policy of being keen to have a zero-warning build.

提交回复
热议问题