From 11ec4451640babb8c3c1e38e9b54cb4c2e678c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0koudlil?= Date: Fri, 22 Mar 2024 18:45:27 +0100 Subject: [PATCH] Add macro to fail compilation if sim time is not supported cfg(r2r__rosgraph_msgs__msg__Clock) attribute is not propagated to user code so this macro can be used to intentionally fail compilation if sim time is not supported. --- r2r/src/utils.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/r2r/src/utils.rs b/r2r/src/utils.rs index cb418cc..5e86e78 100644 --- a/r2r/src/utils.rs +++ b/r2r/src/utils.rs @@ -139,6 +139,22 @@ macro_rules! log_fatal { }} } +/// Causes compile time error if `use_sim_time` is unsupported. +#[cfg(r2r__rosgraph_msgs__msg__Clock)] +#[macro_export] +macro_rules! assert_compiled_with_use_sim_time_support { + () => {}; +} + +/// Causes compile time error if `use_sim_time` is unsupported. +#[cfg(not(r2r__rosgraph_msgs__msg__Clock))] +#[macro_export] +macro_rules! assert_compiled_with_use_sim_time_support { + () => { + compile_error!("assert_compiled_with_use_sim_time_support failed: 'rosgraph_msgs' dependency is missing!"); + }; +} + #[test] fn test_log() { log_debug!("log_test", "debug msg");