Eliminate more warnings in JUCE library code


I’m very happy with warnings hygiene in JUCE 5 library code. It’s possible to turn on -Wall -Wextra -Wpedantic in clang and not get any warnings, which is a great improvement since JUCE 4.

There are still some more warnings which I would like to turn on for my own code, but which trigger on JUCE library code, so until they are fixed there (or an option is added to have different warnings for user/JUCE library code - would love this!) it wouldn’t be convenient to turn them on.

I also tested some warnings which I’m not interested in turning on, but which did find potential improvements to the JUCE code, so I also mention them below.

Most triggered warnings can be fixed, but some can just be silenced locally. For example, -Wglobal-constructors is a good warning in general, but there are dummy global objects in JUCE designed to detect mismatching linking multiple debug/release builds, so this warning should be suppressed around the definition of these objects.

The extra clang warnings which trigger on the JUCE code are:


-Wmissing-variable-declarations (mostly finds unintentionally non-static global variables)

-Wdeprecated (triggered on definition of implicit copy constructor when there is a user-declared destructor)

-Wpacked (see https://www.cleancss.com/explain-command/gcc/4842 for why this could be a useful warning)

-Wdouble-promotion (I was skeptic whether this is an interesting one, but it in fact found non-boring cases in the JUCE library code, so could perhaps be worth turning on in user code as well)

-Wdocumentation (not super important, nice to fix significant issues, e.g., documentation of parameters which mismatches actual parameters).

-Wweak-vtables (nice to have, not very important)



Yes, thank you!