Deprecated is_initialized() (#967)

The function was previously documented as being deprecated, but this change adds compiler warnings if it is used.
Ignore compiler warnings where the function is being tested and change to the preferred usage elsewhere.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This commit is contained in:
Jacob Perron 2020-01-22 14:11:58 -05:00 committed by GitHub
parent 54ad49703a
commit 7a8606fb39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View file

@ -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);

View file

@ -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

View file

@ -28,7 +28,7 @@ class TestPublisher : public ::testing::Test
public:
static void SetUpTestCase()
{
if (!rclcpp::is_initialized()) {
if (!rclcpp::ok()) {
rclcpp::init(0, nullptr);
}
}