"混合申报和code"警告,是否值得解决? [英] "Mixed declaration and code" warning, is it worth addressing?

查看:176
本文介绍了"混合申报和code"警告,是否值得解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近启用 -pedantic 选项对GCC和现在我已经得到了ISO C90不允许混合使用的声明和code大约两三页警告。

I've recently enabled -pedantic option on gcc and now I've got about two or three pages of "ISO C90 forbids mixed declaration and code" warnings.

我的这个项目的目标是能够将其部署到任何的主流的交流编译系统,所以我知道它不会是明智的假设C99将无处不在的支持,但它甚至值得我的时间来解决这些警告?

My goal with this project is to be able to deploy it on any mainstream system with a c compiler, so I realize it wouldn't be wise to assume that C99 will be supported everywhere, but is it even worth my time to address these warnings?

是否还有C编译器系统,在那里,不支持混合申报和code?

Are there still systems out there with c compilers that don't support mixed declaration and code?

推荐答案

好吧,是/是你的意图写在C89 / 90或C99的code?

Well, was/is it your intent to write your code in C89/90 or in C99?

由于这是你似乎要关心的唯一的警告,显然你的code,实际上写的C89 / 90。如果确实是这样,你打算坚持C89 / 90,那么我会坚持严格的C89 / 90和移动所有声明的块的开始。

Since this is the only warning you seem to be concerned about, apparently your code was actually written in C89/90. If it is indeed so and you plan to stick with C89/90, then I'd stick to strict C89/90 and move all declarations to the beginning of the block.

如果,在另一方面,你愿意和规划,切换到C99,则错位的声明将不再是个问题。然后,您的主要关注成为平台/编译器支持。 MS Visual Studio的C编译器C89 / 90的编译器。这是个问题吗? (考虑到GCC适用于Windows平台)。

If, on the other hand, you are willing and planning to switch to C99, then "misplaced" declarations are no longer an issue. Then your main concern becomes the platform/compiler support. MS Visual Studio C compilers are C89/90 compilers. Is this a problem? (Considering that GCC is available on Windows platforms).

这篇关于"混合申报和code"警告,是否值得解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆