Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions ros/src/foxglove_bridge/src/message_definition_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,19 @@ const MessageSpec& MessageDefinitionCache::load_message_spec(
}

// Get the package share directory, or throw a PackageNotFoundError
const std::string share_dir = ament_index_cpp::get_package_share_directory(package);
// Suppress deprecation warnings for this API call. The newer API signature
// (taking std::filesystem::path& as an out parameter) is only available in
// ROS 2 rolling and later distributions. To support older distributions,
// we continue using the old API until all supported distributions have been updated.
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
const std::string share_dir_str = ament_index_cpp::get_package_share_directory(package);
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
const std::filesystem::path share_dir(share_dir_str);

// Get the rosidl_interfaces index contents for this package
std::string index_contents;
Expand All @@ -234,7 +246,7 @@ const MessageSpec& MessageDefinitionCache::load_message_spec(
}

// Read the file
const std::string full_path = share_dir + std::filesystem::path::preferred_separator + *it;
const std::filesystem::path full_path = share_dir / *it;
std::ifstream file{full_path};
if (!file.good()) {
throw DefinitionNotFoundError(definition_identifier.package_resource_name);
Expand Down
Loading