Re: GNU gcc upgrades
Mo McKinlay <mo.mckinlay-ZW9u5aLsJ29O/fpWF/[email protected]>
| Newsgroups | gmane.linux.usability.annoyances |
|---|---|
| Message-ID | <[email protected]> |
> Another slight annoyance, but more to do with gcc rather than Linux is the way after each upgrade to the glibc libraries, suddenly software which compiled perfectly happily under the previous version, even with -Wall switched on, suddenly starts spitting out 100's of warnings (or even worse errors). > > Somehow this makes no sense to me. I could understand 1 or 2 warnings, but why pass from 0 warnings for one version of gcc to not even compiling on the next? > > John Well, there's a few potential causes for this. In the GCC world, gcc 2.95.x adheres to C89, whereas gcc 3.x adheres ot C99 - the latter standard is a bit more strict in certain respects (though C99 will compile fine with C89 compilers, except for a few features that're relatively rarely used and can easily be #ifdef'd around). In the glibc world, glibc is continuously moving towards the standards (and they're not particularly moving goalposts). Some things have caught people out in the past - for example, time() used to be declared in both sys/time.h and time.h. The standard specifies that it should be declared only in time.h. Older code often relied (incorrectly) on the former behaviour, and suddenly failed to compile. As a rule of thumb, if you work to the latest standards, then your code will compile without warnings with both newer and older compilers and libraries. If you work with older standards, you may get bitten. The other thing you can find is that gcc's warning levels have been shifted around. This isn't necessarily stuff that wasn't warned about before, but stuff that -Wall didn't warn about and now does. I tend to use "-W -Wall" with gcc, which warns about everything you'd normally need to worry about. HTH, Mo.