[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Conformant C code, and compiler warnings...
- From: sur-behoffski <sur_behoffski@...>
- Date: Thu, 9 Mar 2023 11:30:21 +1030
G'day,
Frank Mitchell <frank_mitchell_us@yahoo.com> wrote:
> [...]> > P.S. As far as warnings go ... it always amazes me when I build an established
> Project from source and the compiler issues warnings. Some compiler
> incompatibilities are inevitable, but I would think any and every compiler> would catch unused variables, suspicious implicit casts, and the like.
> Just because you *can* do anything in C doesn't mean you *should*.
Over time, compiler toolchains have steadily improved their code flow
analysis and their ability to issue warnings for
"compliant-but-brittle-to-maintain" code constructs... the classic,
as always, being the Apple "goto fail" bug.
There has been a concerted effort to improve the GNU toolchain, and
so code that was previously warning-free, say, five years ago, might
have a dozen or more warnings now. I believe that the same is true
of other toolchains.
Once code becomes well-established, it becomes more difficult to
consider changing it for any reason, including toolchain warnings.
Sometimes a particular version of a library is incorporated wholesale,
because it is easier to maintain compatibility with different
environments (e.g. MSVC, CygWin, GCC toolchains). The original
library may incorporate changes in response to newer toolchain
warnings, but the "portable snapshot" does not. it takes considerable
effort, and a substantial, comprehensive test rig, to make large
changes.
Sometimes a library changes its license, and so source snapshot
is required, as linking against newer versions causes problems.
Incidentally, the large number of warnings when building the Tecgraf
IM/CD/IUP packages under GCC in GNU/Linux was a central reason why I
created, and am maintaining, the "lglicua" adaptor/shim/helper
project on SourceForge. Over time, a *lot* of warnings have been
addressed, but the remainder are much more tricky.
--
cheers,
sur-behoffski (Brenton Hoff)
programmer, Grouse Software