Warnings

To check for warnings while working add a line like this:

#pragma GCC diagnostic warning "-Wall"

after #includes in .C files you are editing. Don't forget to remove this before committing your changes.

Note: On Apple gcc 4.2.1 -Wall can't be enabled this way. Instead the individual warnings need to be enabled as shown below in the WarningReport.h header file.

WarningReport.h

#ifndef WarningReports_H
#define WarningReports_H

#if defined(__linux)
#pragma GCC diagnostic warning "-Wall"
#pragma GCC diagnostic warning "-Wextra"

//#if defined(_MSC_VER)
//TODO -- windows

#elif defined(__APPLE__)

#if defined(__GNUG__)
#define GCC_VERSION (__GNUC__ * 10000 \
                   + __GNUC_MINOR__ * 100 \
                   + __GNUC_PATCHLEVEL__)

#if GCC_VERSION < 40400
#pragma GCC diagnostic warning "-Waddress"
#pragma GCC diagnostic warning "-Waggregate-return"
#pragma GCC diagnostic warning "-Wc++-compat"
#pragma GCC diagnostic warning "-Wcast-align"
#pragma GCC diagnostic warning "-Wcast-qual"
#pragma GCC diagnostic warning "-Wchar-subscripts"
#pragma GCC diagnostic warning "-Wcomment"
#pragma GCC diagnostic warning "-Wconversion"
#pragma GCC diagnostic warning "-Wdisabled-optimization"
#pragma GCC diagnostic warning "-Wfloat-equal"
#pragma GCC diagnostic warning "-Wformat-nonliteral"
#pragma GCC diagnostic warning "-Wformat-y2k"
#pragma GCC diagnostic warning "-Wglobal-constructors"
#pragma GCC diagnostic warning "-Wimplicit"
#pragma GCC diagnostic warning "-Wimplicit-function-declaration"
#pragma GCC diagnostic warning "-Wimplicit-int"
#pragma GCC diagnostic warning "-Wimport"
#pragma GCC diagnostic warning "-Winit-self"
#pragma GCC diagnostic warning "-Winline"
#pragma GCC diagnostic warning "-Winvalid-pch"
#pragma GCC diagnostic warning "-Wmain"
#pragma GCC diagnostic warning "-Wmissing-braces"
#pragma GCC diagnostic warning "-Wmissing-field-initializers"
#pragma GCC diagnostic warning "-Wmissing-format-attribute"
#pragma GCC diagnostic warning "-Wmissing-include-dirs"
#pragma GCC diagnostic warning "-Wmissing-noreturn"
#pragma GCC diagnostic warning "-Wmissing-prototypes"
#pragma GCC diagnostic warning "-Wmost"
#pragma GCC diagnostic warning "-Woverlength-strings"
#pragma GCC diagnostic warning "-Wpacked"
#pragma GCC diagnostic warning "-Wpadded"
#pragma GCC diagnostic warning "-Wparentheses"
#pragma GCC diagnostic warning "-Wpointer-arith"
#pragma GCC diagnostic warning "-Wredundant-decls"
#pragma GCC diagnostic warning "-Wreturn-type"
#pragma GCC diagnostic warning "-Wsequence-point"
#pragma GCC diagnostic warning "-Wshadow"
#pragma GCC diagnostic warning "-Wsign-compare"
#pragma GCC diagnostic warning "-Wstack-protector"
#pragma GCC diagnostic warning "-Wstrict-aliasing"
#pragma GCC diagnostic warning "-Wstrict-overflow"
#pragma GCC diagnostic warning "-Wswitch"
#pragma GCC diagnostic warning "-Wswitch-default"
#pragma GCC diagnostic warning "-Wswitch-enum"
#pragma GCC diagnostic warning "-Wtrigraphs"
#pragma GCC diagnostic warning "-Wundef"
#pragma GCC diagnostic warning "-Wuninitialized"
#pragma GCC diagnostic warning "-Wunreachable-code"
#pragma GCC diagnostic warning "-Wunused"
#pragma GCC diagnostic warning "-Wunused-function"
#pragma GCC diagnostic warning "-Wunused-label"
#pragma GCC diagnostic warning "-Wunused-parameter"
#pragma GCC diagnostic warning "-Wunused-value"
#pragma GCC diagnostic warning "-Wunused-variable"
#pragma GCC diagnostic warning "-Wvariadic-macros"
#pragma GCC diagnostic warning "-Wvolatile-register-var"
#pragma GCC diagnostic warning "-Wwrite-strings"
#else
#pragma GCC diagnostic warning "-Wall"
#pragma GCC diagnostic warning "-Wextra"
#endif
#endif

#endif

#endif