gcc4.4 issues

各位讀者,很抱歉這篇文章是英文的,我當初做筆記的時候,寫成英文了,這樣纔可以在同事之間交流。
而現在確實沒時間翻譯過來了,還望大家理解,謝謝!

If your code builds well using gcc4.3 and below, it may not build
with gcc4.4, which was released in April 2009.

Following are some of the changes that violates c/c++ standard:

1. gcc4.4 does not by default #include stdio.h, or stdlib.h, no
header files are by default included, all header files of
standard c/c++ libraries need to be explicitly included.

2. More warning checks, e.g. if/else partitions.

This code snippet:
if (a)
if (b)
do something here;
else
do something else here;
will cause warnings, you need this:
if (a) {
if (b)
do something here;
else
do something else here;
}

3. Stricter enum checks.
Basically we can not rely on the
rules to evaluate enum members to integers which were
true before; we can not use the integer values of enum
members, we can only use the literal enum members. For
example, we can not use them to compare with integral
values, or members of another enum type. We can only
compare with other enum members of the same type for equality.


4. Use standard ansi c++ include
For C library header files, #include <cstdio> rather than #include <stdio.h>;
And also need to "use namespace std;" because all C functions are put into the
std namespace.

This item is not required now, but since it is standard c++
we should follow it and abandon the old fashion in case some day later our
code fails to build with latest c++ compiler.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章