如何强制执行C89式变量声明在GCC? [英] How to enforce C89-style variable declarations in gcc?
问题描述
我在code基地,主要是下用一点点C ++和大多与海湾合作委员会建立,但有时它需要与MSVC建造工作。微软的C编译器仍然是pretty多C89有一些小的扩展,它仍然不支持混合code和变量定义的单的C ++ / C99。所以,我需要从写找到一种方法,prevent开发商乱序code /而他们正在与海湾合作委员会的工作,否则构建随后与MSVC打破变量定义。如果我使用的gcc -std = C89
然后一切休息时间,因为C ++ - 风格注释不准(可能还有其他的问题太多,但我没有看过这个任何进一步的)。如果我使用的gcc -std = gnu89
则乱序code /变量定义是允许的,这样就不会帮我满意。有任何想法吗 ?我想我只是需要像的gcc -std = C99 -fno-直列可变定义
,如果这样的选择存在。
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 much C89 with a few minor extensions, and it still doesn't support mixed code and variable definitions à la C++/C99. So I need to find a way to prevent developers from writing out-of-order code/variable definitions while they are working with gcc, otherwise the build subsequently breaks with MSVC. If I use gcc -std=c89
then everything breaks because C++-style comments are not allowed (there may be other issues too, but I haven't looked into this any further). If I use gcc -std=gnu89
then the out-of-order code/variable definitions are allowed, so that doesn't help me either. Any ideas ? I guess I just need something like gcc -std=c99 -fno-inline-variable-definitions
, if such an option existed.
推荐答案
您是在 -Wall
-Wextra
-Wstrict的原型
-WOLD式定义
-Wmissing的原型
-Wmissing-声明
和 -Wdeclaration-后声明
选项,描述的<一个HREF =http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>海湾合作委员会的警告信息页面。请注意,这些可能会导致大量的噪音从系统头文件的问题,他们只是警告,所以你得有被渴望有一个零警告建设的政策。
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.
这篇关于如何强制执行C89式变量声明在GCC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!