From 4ca66e33dae609b718cdf3eb4dee3d959c55d3b0 Mon Sep 17 00:00:00 2001 From: Florian Uhlig Date: Thu, 17 Mar 2016 13:19:49 +0100 Subject: [PATCH] Fix compiler warnings. Switch of compiler warnings for part of the code. The compiler flag -Weffc++ of the gcc compiler creates many warnings about non virtual destructor of base classes where the base class is actually a class from boost or from stl. Switch of the compiler flag for the problematic parts of the code using preprocessor statements. There are also such preprocessor guards for code which creates many warnings when using clang. Filter warnings comming from generated files. When using CTest all warnings comming from generated code (Root Dictionaries, code generated by protoc) will be filtered before sending the results to the CDash web server. Remove unused variables or use them. Initialize all data members in initializer lists. Use in initializer list the same order of data members as defined in the class declaration. Declare private copy constructors and assignment operators where needed. Fix format problems in printf statements. Correctly cast the variables. --- fairmq/FairMQParts.h | 2 +- fairmq/FairMQStateMachine.h | 1 + fairmq/logger/logger.h | 10 ++++++++++ fairmq/options/FairProgOptionsHelper.h | 7 +++++++ fairmq/tools/FairMQTools.h | 7 +++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fairmq/FairMQParts.h b/fairmq/FairMQParts.h index dd15bfc7..e499c836 100644 --- a/fairmq/FairMQParts.h +++ b/fairmq/FairMQParts.h @@ -19,7 +19,7 @@ class FairMQParts { public: /// Default constructor - FairMQParts() {}; + FairMQParts() : fParts() {}; /// Copy Constructor FairMQParts(const FairMQParts&) = delete; /// Assignment operator diff --git a/fairmq/FairMQStateMachine.h b/fairmq/FairMQStateMachine.h index f584a9a6..0285a5fa 100644 --- a/fairmq/FairMQStateMachine.h +++ b/fairmq/FairMQStateMachine.h @@ -64,6 +64,7 @@ _Pragma("clang diagnostic ignored \"-Wnon-virtual-dtor\"") #elif defined(__GNUC__) || defined(__GNUG__) _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"") +_Pragma("GCC diagnostic ignored \"-Weffc++\"") #endif // defining the boost MSM state machine diff --git a/fairmq/logger/logger.h b/fairmq/logger/logger.h index fc31b99c..ad090ff2 100644 --- a/fairmq/logger/logger.h +++ b/fairmq/logger/logger.h @@ -14,6 +14,7 @@ #ifndef LOGGER_H #define LOGGER_H + #define BOOST_LOG_DYN_LINK 1 // necessary when linking the boost_log library dynamically #define FUSION_MAX_VECTOR_SIZE 20 @@ -81,12 +82,21 @@ void set_global_log_level( log_op::operation op=log_op::GREATER_EQ_THAN, custom_severity_level threshold=SEVERITY_THRESHOLD ); void set_global_log_level_operation( log_op::operation op=log_op::GREATER_EQ_THAN, custom_severity_level threshold=SEVERITY_THRESHOLD ); + +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#endif + // register a global logger (declaration) BOOST_LOG_GLOBAL_LOGGER(global_logger, boost::log::sources::severity_logger_mt) BOOST_LOG_ATTRIBUTE_KEYWORD(fairmq_logger_timestamp, "TimeStamp", boost::posix_time::ptime) BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity", custom_severity_level) +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic pop +#endif template void init_log_formatter(const boost::log::record_view &view, boost::log::formatting_ostream &os) diff --git a/fairmq/options/FairProgOptionsHelper.h b/fairmq/options/FairProgOptionsHelper.h index 015f7bad..12d34689 100644 --- a/fairmq/options/FairProgOptionsHelper.h +++ b/fairmq/options/FairProgOptionsHelper.h @@ -89,6 +89,10 @@ namespace fairmq return valueStr; } +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#endif //_____________________________________________________________________________________________________________________________ // policy to convert boost variable value into string struct ToString @@ -231,6 +235,9 @@ namespace fairmq }; +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic pop +#endif }; diff --git a/fairmq/tools/FairMQTools.h b/fairmq/tools/FairMQTools.h index d543ee3f..158c98c0 100644 --- a/fairmq/tools/FairMQTools.h +++ b/fairmq/tools/FairMQTools.h @@ -65,6 +65,10 @@ int getHostIPs(map& addressMap) return 0; } +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#endif // below are SFINAE template functions to check for function member signatures of class namespace details { @@ -111,6 +115,9 @@ struct has_BindGetCurrentIndex } // end namespace details +#if defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic pop +#endif // Alias template of the above structs template