From 458dfde81d771c833f8fbd75ed9f35b37db9ad8a Mon Sep 17 00:00:00 2001 From: "DrZiplok@gmail.com" Date: Sat, 27 Nov 2010 23:27:08 +0000 Subject: [PATCH] Move the warning controls for APM out to AP_Common. This makes it easier to grab these for libraries uniformly. git-svn-id: https://arducopter.googlecode.com/svn/trunk@960 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- libraries/AP_Common/AP_Common.h | 48 ++++++++++++++++++++++++++++++++- libraries/AP_Common/menu.cpp | 7 +---- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/libraries/AP_Common/AP_Common.h b/libraries/AP_Common/AP_Common.h index 8ad2f0fbf5..163cd17594 100644 --- a/libraries/AP_Common/AP_Common.h +++ b/libraries/AP_Common/AP_Common.h @@ -16,9 +16,55 @@ #define _AP_COMMON_H #include - #include "include/menu.h" /// simple menu subsystem +//////////////////////////////////////////////////////////////////////////////// +/// @name Warning control +//@{ +// +// Turn on/off warnings of interest. +// +// These warnings are normally suppressed by the Arduino IDE, +// but with some minor hacks it's possible to have warnings +// emitted. This helps greatly when diagnosing subtle issues. +// +#pragma GCC diagnostic warning "-Wall" +#pragma GCC diagnostic warning "-Wextra" +#pragma GCC diagnostic warning "-Wlogical-op" +#pragma GCC diagnostic ignored "-Wredundant-decls" + +// Make some dire warnings into errors +// +// Some warnings indicate questionable code; rather than let +// these slide, we force them to become errors so that the +// developer has to find a safer alternative. +// +#pragma GCC diagnostic error "-Wfloat-equal" + +// The following is strictly for type-checking arguments to printf_P calls +// in conjunction with a suitably modified Arduino IDE; never define for +// production as it generates bad code. +// +#if PRINTF_FORMAT_WARNING_DEBUG +# undef PSTR +# define PSTR(_x) _x // help the compiler with printf_P +# define float double // silence spurious format warnings for %f +#else +// This is a workaround for GCC bug c++/34734. +// +// The C++ compiler normally emits many spurious warnings for the use +// of PSTR (even though it generates correct code). This workaround +// has an equivalent effect but avoids the warnings, which otherwise +// make finding real issues difficult. +// +# undef PROGMEM +# define PROGMEM __attribute__(( section(".progmem.data") )) +# undef PSTR +# define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];})) +#endif + +//@} + //////////////////////////////////////////////////////////////////////////////// /// @name Types /// diff --git a/libraries/AP_Common/menu.cpp b/libraries/AP_Common/menu.cpp index e58f5c444a..499e3ff968 100644 --- a/libraries/AP_Common/menu.cpp +++ b/libraries/AP_Common/menu.cpp @@ -5,6 +5,7 @@ // #include +#include #include #include @@ -12,12 +13,6 @@ #include "include/menu.h" -// workaround for GCC bug c++/34734 -#undef PROGMEM -#define PROGMEM __attribute__(( section(".progmem.data") )) -#undef PSTR -#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];})) - // statics char Menu::_inbuf[MENU_COMMANDLINE_MAX]; Menu::arg Menu::_argv[MENU_ARGS_MAX + 1];