From daf976d25c198fec7d1d2ffe1fc8fb284760326d Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 25 Jan 2022 13:24:34 -0600 Subject: [PATCH] Use SuppressWarning from ign-utils (#295) * Remove SuppressWarning and switch to utils variant * Add aliased version of SuppressWarning Signed-off-by: Michael Carroll --- av/include/ignition/common/AudioDecoder.hh | 6 +- av/include/ignition/common/HWEncoder.hh | 1 - av/include/ignition/common/Video.hh | 6 +- av/include/ignition/common/VideoEncoder.hh | 6 +- events/include/ignition/common/KeyEvent.hh | 6 +- events/include/ignition/common/MouseEvent.hh | 6 +- graphics/include/ignition/common/SubMesh.hh | 1 - include/ignition/common/Console.hh | 14 +- include/ignition/common/Plugin.hh | 6 +- include/ignition/common/PluginLoader.hh | 6 +- include/ignition/common/SuppressWarning.hh | 21 ++- include/ignition/common/Timer.hh | 6 +- .../ignition/common/detail/PluginMacros.hh | 6 +- .../ignition/common/detail/SuppressWarning.hh | 154 ------------------ src/CMakeLists.txt | 1 - test/plugins/CMakeLists.txt | 5 + test/static_assertions/CMakeLists.txt | 3 + 17 files changed, 52 insertions(+), 202 deletions(-) delete mode 100644 include/ignition/common/detail/SuppressWarning.hh diff --git a/av/include/ignition/common/AudioDecoder.hh b/av/include/ignition/common/AudioDecoder.hh index da9479a87..470cb9d6b 100644 --- a/av/include/ignition/common/AudioDecoder.hh +++ b/av/include/ignition/common/AudioDecoder.hh @@ -22,7 +22,7 @@ #include #include -#include +#include namespace ignition { @@ -66,10 +66,10 @@ namespace ignition /// \brief Free audio object, close files, streams. private: void Cleanup(); - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief Private data pointer private: std::unique_ptr data; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/av/include/ignition/common/HWEncoder.hh b/av/include/ignition/common/HWEncoder.hh index 2353a9528..519841627 100644 --- a/av/include/ignition/common/HWEncoder.hh +++ b/av/include/ignition/common/HWEncoder.hh @@ -22,7 +22,6 @@ #include #include -#include #include #include diff --git a/av/include/ignition/common/Video.hh b/av/include/ignition/common/Video.hh index ee5fe14a6..d01cf6929 100644 --- a/av/include/ignition/common/Video.hh +++ b/av/include/ignition/common/Video.hh @@ -21,7 +21,7 @@ #include #include -#include +#include struct AVFormatContext; struct AVCodecContext; @@ -76,10 +76,10 @@ namespace ignition /// \brief free up open Video object, close files, streams private: void Cleanup(); - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief Private data pointer private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/av/include/ignition/common/VideoEncoder.hh b/av/include/ignition/common/VideoEncoder.hh index 9c838e8c9..a8c9ee941 100644 --- a/av/include/ignition/common/VideoEncoder.hh +++ b/av/include/ignition/common/VideoEncoder.hh @@ -24,8 +24,8 @@ #include #include -#include #include +#include // Default bitrate (0) indicates that a bitrate should be calculated when // Start is called. @@ -221,11 +221,11 @@ namespace ignition /// memory. This will also delete any temporary files. public: void Reset(); - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \internal /// \brief Private data pointer private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/events/include/ignition/common/KeyEvent.hh b/events/include/ignition/common/KeyEvent.hh index a318cb2d0..765614210 100644 --- a/events/include/ignition/common/KeyEvent.hh +++ b/events/include/ignition/common/KeyEvent.hh @@ -21,7 +21,7 @@ #include #include -#include +#include namespace ignition { @@ -110,10 +110,10 @@ namespace ignition /// \return this public: KeyEvent& operator=(KeyEvent&& other); - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief Private data pointer private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/events/include/ignition/common/MouseEvent.hh b/events/include/ignition/common/MouseEvent.hh index b57ad5c4d..98cc5ed7e 100644 --- a/events/include/ignition/common/MouseEvent.hh +++ b/events/include/ignition/common/MouseEvent.hh @@ -21,7 +21,7 @@ #include #include -#include +#include namespace ignition { @@ -203,11 +203,11 @@ namespace ignition /// \return this public: MouseEvent &operator=(const MouseEvent &_other); - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \internal /// \brief Private data pointer private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/graphics/include/ignition/common/SubMesh.hh b/graphics/include/ignition/common/SubMesh.hh index 3b4c7721c..10878b653 100644 --- a/graphics/include/ignition/common/SubMesh.hh +++ b/graphics/include/ignition/common/SubMesh.hh @@ -28,7 +28,6 @@ #include #include -#include namespace ignition { diff --git a/include/ignition/common/Console.hh b/include/ignition/common/Console.hh index 7cd89cb97..e5245fbbf 100644 --- a/include/ignition/common/Console.hh +++ b/include/ignition/common/Console.hh @@ -25,7 +25,7 @@ #include #include -#include +#include namespace ignition { @@ -123,11 +123,11 @@ namespace ignition public: std::ofstream *stream; }; - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief Stores the full path of the directory where all the log files /// are stored. private: std::string logDirectory; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING /// \brief True if initialized. private: bool initialized; @@ -212,10 +212,10 @@ namespace ignition public: std::mutex syncMutex; }; - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief Prefix to use when logging to file. private: std::string prefix; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; /// \class Console Console.hh common/common.hh @@ -275,10 +275,10 @@ namespace ignition /// \brief The level of verbosity, the default level is 1. private: static int verbosity; - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief A custom prefix. See SetPrefix(). private: static std::string customPrefix; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/include/ignition/common/Plugin.hh b/include/ignition/common/Plugin.hh index 92294d511..ee8352576 100644 --- a/include/ignition/common/Plugin.hh +++ b/include/ignition/common/Plugin.hh @@ -24,7 +24,7 @@ #include #include -#include +#include namespace ignition { @@ -180,10 +180,10 @@ namespace ignition private: InterfaceMap::iterator PrivateGetOrCreateIterator( const std::string &_interfaceName); - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief PIMPL pointer to the implementation of this class. private: const std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING /// \brief Virtual destructor public: virtual ~Plugin(); diff --git a/include/ignition/common/PluginLoader.hh b/include/ignition/common/PluginLoader.hh index dee83d7ee..8b3b5b642 100644 --- a/include/ignition/common/PluginLoader.hh +++ b/include/ignition/common/PluginLoader.hh @@ -25,8 +25,8 @@ #include #include -#include #include +#include namespace ignition { @@ -91,10 +91,10 @@ namespace ignition private: const PluginInfo *PrivateGetPluginInfo( const std::string &_pluginName) const; - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief PIMPL pointer to class implementation private: std::unique_ptr dataPtr; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } } diff --git a/include/ignition/common/SuppressWarning.hh b/include/ignition/common/SuppressWarning.hh index d989fec29..a4e00c8db 100644 --- a/include/ignition/common/SuppressWarning.hh +++ b/include/ignition/common/SuppressWarning.hh @@ -15,11 +15,15 @@ * */ - #ifndef IGNITION_COMMON_SUPPRESSWARNING_HH_ #define IGNITION_COMMON_SUPPRESSWARNING_HH_ -#include +#include + +#pragma message("ign-common SuppressWarning is deprecated, use ign-utils") +// These macros have been moved to ign-utils so they may be more broadly used. +// The implementations are aliases to those implementations and are deprecated +// in ign-common5 and are to be removed in ign-common6 // This header contains cross-platform macros for suppressing warnings. Please // only use these macros responsibly when you are certain that the compiler is @@ -50,10 +54,10 @@ /// of our implementation) that the pointer is definitely not pointing to a more /// derived type. #define IGN_COMMON_WARN_IGNORE__DELETE_NON_VIRTUAL_DESTRUCTOR \ - DETAIL_IGN_COMMON_WARN_IGNORE__DELETE_NON_VIRTUAL_DESTRUCTOR + IGN_UTILS_WARN_IGNORE__NON_VIRTUAL_DESTRUCTOR #define IGN_COMMON_WARN_RESUME__DELETE_NON_VIRTUAL_DESTRUCTOR \ - DETAIL_IGN_COMMON_WARN_RESUME__DELETE_NON_VIRTUAL_DESTRUCTOR + IGN_UTILS_WARN_RESUME__NON_VIRTUAL_DESTRUCTOR /// \brief Microsoft Visual Studio does not automatically export the interface @@ -62,14 +66,9 @@ /// choose to suppress the warning instead of needlessly adding the class /// information to the DLL interface. #define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING \ - DETAIL_IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING #define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING \ - DETAIL_IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - -// TODO(anyone): Add more warning types as they become relevant. -// Do not add warning -// types to suppress unless they are genuinely necessary. + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING #endif diff --git a/include/ignition/common/Timer.hh b/include/ignition/common/Timer.hh index 7fda12dba..f53dfa0a9 100644 --- a/include/ignition/common/Timer.hh +++ b/include/ignition/common/Timer.hh @@ -18,7 +18,7 @@ #define IGNITION_COMMON_TIMER_HH_ #include -#include +#include #include #include @@ -59,13 +59,13 @@ namespace ignition return out; } - IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief The time of the last call to Start private: std::chrono::steady_clock::time_point start; /// \brief The time when Stop was called. private: std::chrono::steady_clock::time_point stop; - IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING + IGN_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING /// \brief True if the timer is running. private: bool running; diff --git a/include/ignition/common/detail/PluginMacros.hh b/include/ignition/common/detail/PluginMacros.hh index 5e1312cce..733c91938 100644 --- a/include/ignition/common/detail/PluginMacros.hh +++ b/include/ignition/common/detail/PluginMacros.hh @@ -25,7 +25,7 @@ #include #include #include "ignition/common/PluginInfo.hh" -#include "ignition/common/SuppressWarning.hh" +#include "ignition/utils/SuppressWarning.hh" #if defined _WIN32 || defined __CYGWIN__ @@ -63,7 +63,7 @@ #define DETAIL_IGN_COMMON_BEGIN_ADDING_PLUGINS \ DETAIL_IGN_COMMON_REGISTER_PLUGININFO_META_DATA \ -IGN_COMMON_WARN_IGNORE__DELETE_NON_VIRTUAL_DESTRUCTOR \ +IGN_UTILS_WARN_IGNORE__NON_VIRTUAL_DESTRUCTOR \ /* This struct attempts to make sure that the macro is being called from */ \ /* a global namespace */ \ struct IGN_macro_must_be_used_in_global_namespace; \ @@ -172,7 +172,7 @@ IGN_COMMON_WARN_IGNORE__DELETE_NON_VIRTUAL_DESTRUCTOR \ } \ return visitedPlugins.size() - _pluginId; \ } \ -IGN_COMMON_WARN_RESUME__DELETE_NON_VIRTUAL_DESTRUCTOR +IGN_UTILS_WARN_RESUME__NON_VIRTUAL_DESTRUCTOR #endif diff --git a/include/ignition/common/detail/SuppressWarning.hh b/include/ignition/common/detail/SuppressWarning.hh deleted file mode 100644 index 535e7fa34..000000000 --- a/include/ignition/common/detail/SuppressWarning.hh +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2017 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -#ifndef IGNITION_COMMON_DETAIL_SUPPRESSWARNING_HH_ -#define IGNITION_COMMON_DETAIL_SUPPRESSWARNING_HH_ - -#define DETAIL_IGN_COMMON_STRINGIFY(x) #x - -/* cppcheck-suppress */ - -// BEGIN / FINISH Macros - -#if defined __clang__ - - #define DETAIL_IGN_COMMON_BEGIN_WARN_SUP_PUSH \ - _Pragma("clang diagnostic push") - - - #define DETAIL_IGN_COMMON_WARN_SUP_HELPER_2(w) \ - DETAIL_IGN_COMMON_STRINGIFY(clang diagnostic ignored w) - - - #define DETAIL_IGN_COMMON_WARN_SUP_HELPER(w) \ - _Pragma(DETAIL_IGN_COMMON_WARN_SUP_HELPER_2(w)) - - - #define DETAIL_IGN_COMMON_WARN_RESUME \ - _Pragma("clang diagnostic pop") - - -#elif defined __GNUC__ - - // NOTE: clang will define both __clang__ and __GNUC__, and it seems that - // clang will gladly accept GCC pragmas. Even so, if we want the pragmas to - // target the "correct" compiler, we should check if __clang__ is defined - // before checking whether __GNUC__ is defined. - - #define DETAIL_IGN_COMMON_BEGIN_WARN_SUP_PUSH \ - _Pragma("GCC diagnostic push") - - - #define DETAIL_IGN_COMMON_WARN_SUP_HELPER_2(w) \ - DETAIL_IGN_COMMON_STRINGIFY(GCC diagnostic ignored w) - - - #define DETAIL_IGN_COMMON_WARN_SUP_HELPER(w) \ - _Pragma(DETAIL_IGN_COMMON_WARN_SUP_HELPER_2(w)) - - - #define DETAIL_IGN_COMMON_WARN_RESUME \ - _Pragma("GCC diagnostic pop") - - -#elif defined _MSC_VER - - - #define DETAIL_IGN_COMMON_BEGIN_WARN_SUP_PUSH \ - __pragma(warning(push)) - - - #define DETAIL_IGN_COMMON_WARN_SUP_HELPER(w) \ - __pragma(warning(disable: w)) - - - #define DETAIL_IGN_COMMON_WARN_RESUME \ - __pragma(warning(pop)) - - -#else - - // Make these into no-ops if we don't know the type of compiler - - #define DETAIL_IGN_COMMON_BEGIN_WARN_SUP_PUSH - - - #define DETAIL_IGN_COMMON_WARN_SUP_HELPER(w) - - - #define DETAIL_IGN_COMMON_WARN_RESUME - - -#endif - - -#define DETAIL_IGN_COMMON_BEGIN_WARNING_SUPPRESSION(warning_token) \ - DETAIL_IGN_COMMON_BEGIN_WARN_SUP_PUSH \ - DETAIL_IGN_COMMON_WARN_SUP_HELPER(warning_token) - - - -// Warning Tokens -#if defined __GNUC__ || defined __clang__ - - #define DETAIL_IGN_COMMON_WARN_IGNORE__DELETE_NON_VIRTUAL_DESTRUCTOR \ - DETAIL_IGN_COMMON_BEGIN_WARNING_SUPPRESSION("-Wdelete-non-virtual-dtor") - - #define DETAIL_IGN_COMMON_WARN_RESUME__DELETE_NON_VIRTUAL_DESTRUCTOR \ - DETAIL_IGN_COMMON_WARN_RESUME - - - // There is no analogous warning for this in GCC or Clang so we just make - // blank macros for this warning type. - #define DETAIL_IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - #define DETAIL_IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - -#elif defined _MSC_VER - - #define DETAIL_IGN_COMMON_WARN_IGNORE__DELETE_NON_VIRTUAL_DESTRUCTOR \ - DETAIL_IGN_COMMON_BEGIN_WARNING_SUPPRESSION(4265) - - #define DETAIL_IGN_COMMON_WARN_RESUME__DELETE_NON_VIRTUAL_DESTRUCTOR \ - DETAIL_IGN_COMMON_WARN_RESUME - - - #define DETAIL_IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING \ - DETAIL_IGN_COMMON_BEGIN_WARNING_SUPPRESSION(4251) - - #define DETAIL_IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING \ - DETAIL_IGN_COMMON_WARN_RESUME - - -#else - - // If the compiler is unknown, we simply leave these macros blank to avoid - // compilation errors. - - #define DETAIL_IGN_COMMON_WARN_IGNORE__DELETE_NON_VIRTUAL_DESTRUCTOR - #define DETAIL_IGN_COMMON_WARN_RESUME__DELETE_NON_VIRTUAL_DESTRUCTOR - - - #define DETAIL_IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING - #define DETAIL_IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING - - -#endif - - -#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b36e0af24..ca25e7ff6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,6 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} ignition-utils${IGN_UTILS_VER}::ignition-utils${IGN_UTILS_VER} ) - # This is required by the WorkerPool::WaitForResults(const Time &_timeout) # TODO(anyone): IGN_DEPRECATED(4). Remove this part when the method is removed target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE diff --git a/test/plugins/CMakeLists.txt b/test/plugins/CMakeLists.txt index 63e24a7e3..9c82a014c 100644 --- a/test/plugins/CMakeLists.txt +++ b/test/plugins/CMakeLists.txt @@ -1,8 +1,13 @@ add_library(IGNBadPluginAlign SHARED BadPluginAlign.cc) +target_link_libraries(IGNBadPluginAlign PRIVATE ${PROJECT_LIBRARY_TARGET_NAME}) add_library(IGNBadPluginAPIVersionNew SHARED BadPluginAPIVersionNew.cc) +target_link_libraries(IGNBadPluginAPIVersionNew PRIVATE ${PROJECT_LIBRARY_TARGET_NAME}) add_library(IGNBadPluginAPIVersionOld SHARED BadPluginAPIVersionOld.cc) +target_link_libraries(IGNBadPluginAPIVersionOld PRIVATE ${PROJECT_LIBRARY_TARGET_NAME}) add_library(IGNBadPluginSize SHARED BadPluginSize.cc) +target_link_libraries(IGNBadPluginSize PRIVATE ${PROJECT_LIBRARY_TARGET_NAME}) add_library(IGNDummyPlugins SHARED DummyPlugins.cc) +target_link_libraries(IGNDummyPlugins PRIVATE ${PROJECT_LIBRARY_TARGET_NAME}) set_property(TARGET IGNBadPluginAlign PROPERTY CXX_STANDARD 11) set_property(TARGET IGNBadPluginAPIVersionNew PROPERTY CXX_STANDARD 11) diff --git a/test/static_assertions/CMakeLists.txt b/test/static_assertions/CMakeLists.txt index 4a71272b8..b3ba61b29 100644 --- a/test/static_assertions/CMakeLists.txt +++ b/test/static_assertions/CMakeLists.txt @@ -18,6 +18,9 @@ if (UNIX) set_target_properties(${test} PROPERTIES EXCLUDE_FROM_ALL TRUE EXCLUDE_FROM_DEFAULT_BUILD TRUE) + target_link_libraries(${test} PRIVATE + ${PROJECT_LIBRARY_TARGET_NAME} + ) if (Rflag) target_compile_options(${test} PRIVATE ${flag}) endif()