[Geany-devel] [PATCH 2/3] Prevent -Wmissing-prototypes report warning when compiling a plugin
Nick Treleaven
nick.treleaven at xxxxx
Thu Jun 10 11:49:11 UTC 2010
On Thu, 10 Jun 2010 13:33:44 +0200
Jiří Techet <techet at gmail.com> wrote:
> On Thu, Jun 10, 2010 at 13:05, Nick Treleaven
> <nick.treleaven at btinternet.com> wrote:
> > On Wed, 9 Jun 2010 21:40:58 +0200
> > Jiří Techet <techet at gmail.com> wrote:
> >
> >> Signed-off-by: Jiří Techet <techet at gmail.com>
> >> ---
> >> src/plugindata.h | 2 ++
> >
> >> + gint plugin_version_check(gint abi_ver);\
> >> gint plugin_version_check(gint abi_ver) \
> >> { \
> >
> > Why is this necessary?
> >
>
> If you don't compile the plugins with -Wmissing-prototypes then you
> don't get any warnings if you use a function that hasn't been
> declared (imagine you make a typo in a call of an API function or any
> of your internal functions). The plugin compiles just fine, but then
> it doesn't get loaded by geany on runtime and you have to start
> searching for what symbol is missing (using LD_DEBUG).
Wouldn't you get a warning with -Wall:
int main(int argc, char **argv)
{
foo();
return 0;
}
$ gcc -c untitled.c -Wall
untitled.c: In function ‘main’:
untitled.c:28: warning: implicit declaration of function ‘foo’
>
> -Wmissing-prototypes requires that for every non-static function there
> is a previous declaration before it is defined/used. This is normally
> satisfied because these are in the header files - this macro is just
> an exceptional case.
>
> In general, I would recommend that geany uses a slightly more strict
> set of warning options. I find the options used by gnome-common as a
> reasonable set:
>
> -Wall -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-sign-compare
>
> You might consider using them for the whole geany.
This is (probably) less strict than our recommended warnings, see the
HACKING file (-W and -ansi):
http://geany.org/manual/dev/hacking.html#coding
(Personally I also use -Werror with -Wno-unused-parameter for Geany)
Regards,
Nick
More information about the Devel
mailing list