[Geany-devel] Ideas on increasing quality of plugins

Colomban Wendling lists.ban at xxxxx
Sun Mar 13 02:57:59 UTC 2011

Le 13/03/2011 02:38, Lex Trotman a écrit :
> On 13 March 2011 09:34, Colomban Wendling <lists.ban at herbesfolles.org> wrote:
>> [...]
>>  * -Warray-bounds: warns about some out-of-bound array subscripting
>>  * -Wformat: warns about wrong format/arguments in printf-like functions
>>  * -Wimplicit-int: warns if the return type of a function is not missing
> Actually warns when the function type IS missing, but know what you mean :-)

Woops! I must have reworded my sentence incorrectly :D

>>  [...]
>> All of these but -Wpointer-arith, -Wshadow, -Wundef and -Wwrite-strings
>> are part of GCC's -Wall.
>> Maybe we might directly use -Wall, but it warns about some things that
>> are not really needed, such as unused functions.
>> Actually, apart -Wwrite-strings, these flags don't show so much warnings :)
>> So (once again), do these flags seems reasonable to you?
> Well if they are warnings only, the more the merrier, I'd use -Wall
> and -Wextras but noting that there is a possibility that some plugin
> might need a customised list if there is a good reason why it is
> correct and can't reasonably avoid some warning.  Up to the plugin dev
> to tell us why, but hey we're reasonable aren't we? :-)

The problem of -Wextra is that it adds -Wunused-parameter, which is a
bit annoying when writing callbacks (you get tons of them, and you don't
have to fix them).
But it adds some cool stuff too (for example -Wmissing-parameter-type
and -Wold-style-declaration). Maybe we would like to use -Wall -Wextra
-Wno-unused-parameter, or only pick the warning we like from -Wextra.

I don't think we should add too much warnings with false-positive (like
-Wunused-parameter) by default, because they are likely to:
 * make the unexperienced programmer try to fix them, though actually
they shouldn't be [1];
 * "hide" some more interesting warnings between plenty of false ones;
 * annoy some developers without good reason.

> Note most developers compile Geany itself with -Wall at least (iaw the
> Hacking file) and Nick has some extras he likes.

Of course -- I personally use the following for all my builds: :D
-Wall -W -Wunused -Wunreachable-code -Wformat=2 -Wundef -Wshadow
-Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wconversion
-Waggregate-return -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute
-Wredundant-decls -Wnested-externs -pedantic
-Werror-implicit-function-declaration -fshow-column

But these are maybe a little too much, they usually generate a bunch of
warnings that should not be "fixed" since they are false-positive actually.

> Also note that some warnings need at least -O2 so the compiler does
> the dataflow tracing needed to detect the warning.

Right, but -O2 also have some drawbacks when debugging, so I'm not sure
we want to add it by default.

> PS we are only talking about gcc flags here but I think we only supprt
> gcc even on Windows, right Enrico?

Actually I check whether the compiler understand each flag, so it would
be easy to support any compiler. I only talk about GCC warnings because
I only know GCC's flags, but if somebody knows some other, we might add


[1] for example, hiding an unused parameter warning by faking a usage
(like "(void)param") generally only bloats the code without any benefit

More information about the Devel mailing list