On Thu, Jun 10, 2010 at 13:49, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Thu, 10 Jun 2010 13:33:44 +0200 Jiří Techet techet@gmail.com wrote:
On Thu, Jun 10, 2010 at 13:05, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Wed, 9 Jun 2010 21:40:58 +0200 Jiří Techet techet@gmail.com wrote:
Signed-off-by: Jiří Techet techet@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’
Ah, sorry, you're right, this isn't the case - it's a different one. Imagine you have:
foo.h: void foo(void);
foo.c: #include "foo.h"
void foo(void) { printf("foo"); }
main.c: #include "foo.h"
int main(int argc, char **argv) { foo(); return 0; }
This is OK. Now you rename foo(void) in foo.c to foobar(void) but forget to update the header. It compiles just fine because main.c finds the declaration of foo(void) in foo.h, but its implementation is missing (so the compiler thinks it's an extern symbol, but it's not actually defined anywhere).
Just a note if you wish to use it - the declarations with no arguments have to be declared as
void foo(void);
and not
void 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):
I would have to check what exactly -W and -ansi consist of but I think they don't contain -Wmissing-prototypes.
Jiri