Enable a new compiler warning, fix any issues that ensue #4
completed by: Jacob Burroughs
mentors: Andrei
BRL-CAD's sources are compiled with a number of build flags including numerous warning flags. By default, we treat all warnings as errors and we turn on nearly every warning that the compiler is capable of producing and then we fix them. When you do this systematically and consistently, it can greatly improve code quality. Help us improve BRL-CAD's code quality even more. We already compile with the following gcc/clang warning flags:
-pedantic -Wall -Wextra -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long -Wno-variadic-macros -Werror
This task involves enabling any new warning flag that is not already explicitly enabled or enabled by default, and then fixing the warnings that result.
Post a patch for review that enables the new flag, fixes at least one warning, and post a full build log (with "make -k" so we can get an estimate of how many issues need to be fixed).
You can enable the build flag by adding a CHECK_C_FLAG(your_flag_here) line in:
- misc/CMake/BRLCAD_CompilerFlags.cmake
Add your line after the "Wall" checks (search for Wall) similar to the numerous other flags being tested. Don't worry about setting it as a C++/CXX flag unless you're feeling adventurous. See the GCC or Clang manual page for a list of warning flags that can be enabled but some unconfirmed possibilities include:
- Wcast-qual
- Wredundant-decls
- Wunreachable-code
- Wmissing-declarations
- Wmissing-prototypes
- Wstrict-prototypes
- Wdocumentation (for Doxygen comments)
- Wfour-char-constants
- Wtraditional
- Wbad-function-cast
- Wc++-compat
- ... many many others ... really, see the GCC manpage and try enabling one
How to approach this task? Add your flag, make sure the build halts because something was detected, then run "make -k" to see just how many were detected. Then try to fix just one of them. If you are successful fixing one of them, submit your make -k log and a patch that fixes one and turns on the flag and get started on fixing the rest.
You'll be expected to fix some portion of the warnings reported, but this will be determined on a case-by-case basis depending on how complicated the warnings are and how many there are.