diff --git a/rclcpp/include/rclcpp/utilities.hpp b/rclcpp/include/rclcpp/utilities.hpp index 606636ed0a..6194aaaa69 100644 --- a/rclcpp/include/rclcpp/utilities.hpp +++ b/rclcpp/include/rclcpp/utilities.hpp @@ -154,6 +154,7 @@ ok(rclcpp::Context::SharedPtr context = nullptr); * \return true if the context is initialized, and false otherwise */ RCLCPP_PUBLIC +[[deprecated("use the function ok() instead, which has the same usage.")]] bool is_initialized(rclcpp::Context::SharedPtr context = nullptr); diff --git a/rclcpp/test/test_init.cpp b/rclcpp/test/test_init.cpp index 6e51ccd6c3..bee35f3992 100644 --- a/rclcpp/test/test_init.cpp +++ b/rclcpp/test/test_init.cpp @@ -17,6 +17,14 @@ #include "rclcpp/exceptions.hpp" #include "rclcpp/utilities.hpp" +#if !defined(_WIN32) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#else // !defined(_WIN32) +# pragma warning(push) +# pragma warning(disable: 4996) +#endif + TEST(TestInit, is_initialized) { EXPECT_FALSE(rclcpp::is_initialized()); @@ -50,3 +58,9 @@ TEST(TestInit, initialize_with_unknown_ros_args) { EXPECT_FALSE(rclcpp::is_initialized()); } + +#if !defined(_WIN32) +# pragma GCC diagnostic pop +#else // !defined(_WIN32) +# pragma warning(pop) +#endif diff --git a/rclcpp/test/test_publisher.cpp b/rclcpp/test/test_publisher.cpp index 6719197ce9..2fad5cd2ae 100644 --- a/rclcpp/test/test_publisher.cpp +++ b/rclcpp/test/test_publisher.cpp @@ -28,7 +28,7 @@ class TestPublisher : public ::testing::Test public: static void SetUpTestCase() { - if (!rclcpp::is_initialized()) { + if (!rclcpp::ok()) { rclcpp::init(0, nullptr); } }