Attempt to enable all Warnings

Hi @juceDevs,

I come here because I have a question about warnings.
Here is my situation, on the project I’m working on, we are trying to enable all possible warnings, with the optimistic objective (maybe too optimistic ^^) of having, one day, a project where all the warnings are activated and no warning is spotted by the compiler.
But I am currently experiencing a problem with that, because some warnings flags a great number of warnings in my project and in Juce, and those warnings are all mixed together which makes it difficult to know if there is still warnings from the project I’m working on. I have, for example add the flag “-Wfloat-equal” and got 300 warnings from both projects combined * sad *.
I do not know which warnings you are using in Juce framework, so it’s probable that some of the warning flags I try to add are no relevant in Juce framework.

So I’m wondering if there is any way to disable the warnings coming from Juce framework directly from Projucer ? So the solution generated would automatically display the warnings coming from non-Juce source files.

Thanks in advance for your time!
Xav.

We go to great lengths to remove all warnings from our code, and use some pretty hardcore warning levels in our test builds. Certainly compared to most other libraries, we’re very very warning-free!

But that -Wfloat-equal one is really annoying because all the things it moans about are false alarms, and not mistakes, and I’ve personally never known the warning to catch any genuine problems. I guess that if people are going to use it we should wrap some pragmas to avoid it triggering in our code.

Was it just that one flag that caused problems?

1 Like

Thanks @jules for you answer :slight_smile:

Actually, the first time, I have added the flag “-Weverything” on xcode, which enable all the warnings flags.
This generated so much warning, it reachs xcode limits with more that 1000 warnings and, for some file, more than 200 warnings :joy:

So I’m now adding a few flags at the time and see the ones that triggerring warnings in Juce Framework and in my project.
Currently, on the flags I have activated, only two flags have generates warnings in Juce files : “-Wfloat-equal” and “-Wextra-semi”.
I will post the complete list of the flags that trigger warnings in Juce framework on xcode when I will have finish to try them :wink:

Is there a file listing the warnings flags that you are using in Juce framework? So people can match the warning level of their project to the level of Juce Framework.

Ah, thanks, I’ll take a look at the -Wextra-semi ones!

You can look at the flags we use in projects like the projucer, which will have a lot turned on.

1 Like

Hi @jules,

As I said a week ago, I give you the list of warnings that I’ve tested.
I have based myself on this document https://clang.llvm.org/docs/DiagnosticsReference.html
Some of the warning I have tested may not be relevant with Clang on OSX, but I’ve tried them anyway, just to be sure.
For your information, I’ve tested those flags on JUCE 4.3.0.

List of all the warning flags that doesn’t generate any warning in Juce :
-Wall -Wextra -Wpedantic -Wconversion -Wunreachable-code -Weffc++ -Wabstract-vbase-init -Warc-repeated-use-of-weak -Warray-bounds-pointer-arithmetic -Wassign-enum -Watomic-properties -Wauto-import -Wbad-function-cast -Wc+±compat -Wc++11-compat -Wc++11-extensions -Wc++11-narrowing -Wc++11-compat-pedantic -Wc++11-long-long -Wc++1z-extensions -Wc++98-c++11-c++14-compat-pedantic -Wc++98-c++11-compat-pedantic -Wc11-extensions -Wcast-qual -Wchar-subscripts -Wclass-varargs -Wcomment -Wcomplex-component-init -Wconditional-uninitialized -Wconsumed -Wcstring-format-directive -Wcustom-atomic-properties -Wdelegating-ctor-cycles -Wdelete-non-virtual-dtor -Wdeprecated-implementations -Wdirect-ivar-access -Wdollar-in-identifier-extension -Wduplicate-enum -Wduplicate-method-arg -Wduplicate-method-match -Wempty-translation-unit -Wexplicit-ownership-type -Wextended-offsetof -Wflexible-array-extensions -Wfloat-conversion -Wformat-non-iso -Wfour-char-constants -Wgnu -Widiomatic-parentheses -Wignored-qualifiers -Wimplicit -Wimplicit-atomic-properties -Wimplicit-function-declaration -Wimplicit-retain-self -Wimport-preprocessor-directive-pedantic -Wincomplete-module -Winfinite-recursion -Wkeyword-macro -Wlanguage-extension-token -Wlong-long -Wloop-analysis -Wmain -Wmethod-signatures -Wmicrosoft -Wmismatched-tags -Wmissing-braces -Wmissing-field-initializers -Wmissing-method-return-type -Rmodule-build -Wmost -Wnested-anon-types -Wnewline-eof -Wnon-gcc -Wnon-modular-include-in-module -Wnon-virtual-dtor -Wnullability-extension -Wnullable-to-nonnull-conversion -Wobjc-interface-ivars -Wobjc-missing-property-synthesis -Wover-aligned -Woverlength-strings -Woverloaded-virtual -Woverriding-method-mismatch -Rpass -Rpass-analysis -Rpass-missed -Wpointer-arith -Wpragmas -Wreceiver-forward-class -Rremark-backend-plugin -Wreorder -Wreserved-user-defined-literal -Wretained-language-linkage -Rsanitize-address -Wselector -Wself-assign -Wself-move -Wsemicolon-before-method-body -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wsometimes-uninitialized -Wsource-uses-openmp -Wstatic-in-inline -Wstrict-prototypes -Wstring-conversion -Wsuper-class-method-mismatch -Wtautological-compare -Wthread-safety -Wthread-safety-beta -Wthread-safety-negative -Wthread-safety-verbose -Wuninitialized -Wunknown-pragmas -Wunnamed-type-template-args -Wunneeded-internal-declaration -Wunneeded-member-function -Wunreachable-code-aggressive -Wunsupported-dll-base-class-template -Wunused -Wunused-function -Wunused-macros -Wunused-member-function -Wunused-parameter -Wused-but-marked-unused -Wvariadic-macros -Wvector-conversion -Wvla -Wvla-extension -Wweak-template-vtables -Wzero-length-array

List of the warning flags that trigger warnings in Juce with the approximative number of warning generated:
-Wbind-to-temporary-copy - 010
-Wcast-align - 060
-Wextra-semi - 024
-Wcovered-switch-default - 050
-Wdate-time - 002
-Wdeprecated - 030
-Wdisabled-macro-expansion - 018
-Wdocumentation - 014
-Wdocumentation-pedantic - 018
-Wdocumentation-unknown-command - 017
-Wfloat-equal - 234
-Wheader-hygiene - 002
-Wimplicit-fallthrough - 100
-Wmissing-noreturn - 002
-Wmissing-prototypes - 021
-Wmissing-variable-declarations - 017
-Wold-style-cast - too much to count : exceed the limit of 200 for some files
-Wpacked - 060
-Wpadded - too much to count : exceed the limit of 200 for some files and 1000 on the project
-Wreserved-id-macro - 040
-Wshift-sign-overflow - 003
-Wstrict-selector-match - 005
-Wswitch-enum - 060
-Wundeclared-selector - 036
-Wundef - too much to count : exceed the limit of 200 for some files
-Wundefined-reinterpret-cast - 001
-Wunused-exception-parameter - 001
-Wweak-vtables - too much to count : exceed the limit of 200 for some files

I hope this will help you to enhance Juce quality.
Thanks again for your time ! :slight_smile:
Xav.

3 Likes

I tried to enable all the Xcode warnings above by pasting them into the “Custom Xcode Flags” field in Projucer. But Xcode will refuse to open the project, saying that it’s unable to parse it.

Am I doing it wrong?

Just don’t. There are contradicting flags in this mode (see discussions on clang ML).

Thanks!

So what is the recommended way to enable a reasonably strict level of compiler warnings in Xcode via Projucer? Or does “Just don’t” mean that I shouldn’t do it at all?

Here is my list, that kept me safe so far:

-Werror 
-Wall 
-Wshadow 
-Wno-missing-field-initializers 
-Wshorten-64-to-32 
-Wstrict-aliasing 
-Wuninitialized 
-Wunused-parameter 
-Wconversion 
-Wsign-compare 
-Wint-conversion 
-Woverloaded-virtual 
-Wreorder 
-Wconstant-conversion 
-Wsign-conversion

Did I miss some important ones?

1 Like

Thank you, but how did you enable those? I tried pasting them in Projucer (Custom Xcode Flags), and still get the error:

Project cannot be opened because the project file cannot be parsed.

I’m on JUCE 5.4.1, Xcode 8.3.2

Hmm, I put it there, and it works for me:

I’m on XCode 9.4.1 (latest stable, even though Apple considers 10 stable, I beg to differ :slight_smile: )

Well, you know what they say, a picture says more than a thousand words!
I had pasted the flags into the wrong box! :smiley:

I pasted them into Custom Xcode Flags (under the separate Debug/Release targets) rather than Extra Compiler Flags

Now everything works as expected, and I have a ton of warnings to fix :slight_smile:

Thanks a lot!

Just in case you missed it: there is now for a while a shortcut to enable a useful set of warnings via Projucer:

2 Likes