[Flac-dev] Two GCC warnings flags you should enable ASAP
Erik de Castro Lopo
erikd-flac at mega-nerd.com
Wed Sep 12 07:02:25 PDT 2007
Erik de Castro Lopo wrote:
> Sorry, I don't want to seem too pushy on this issue, but I consider
> -Wmissing-prototypes a really important issue. It bit me really
> badly once and has been a hobby horse of mine ever since.
I've done some more investigation of this issue. It turns out
that the dangerous scenario I outline in my previous email is
actually caught by the -Wall flag which you already use.
The -Wmissing-prototype warning flag catches a related (and even more
subtle) problem which the -Wall and -W/-Wextra flags ignore.
Consider three files:
first.c
second.c
second.h
The file first.c includes second.h which defines function X, with the
implementation of function X being in second.c. Now consider the case
where second.c does not include second.h and the implementation in
second.c does not match the prototype in second.h. In this case, first.c
which includes second.h expects function X to behave as it was specified
in the header, but the implementation in second.c doesn't match.
This is a recipie for pain very similar to what I describe in my previous
email. However, like the previous problem, the C++ linker would catch the
mis-match.
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"The X-files is too optimistic. The truth is not out there."
-- Anthony Ord
More information about the Flac-dev
mailing list