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.
This commit is contained in:
Martin Škoudlil 2024-03-22 18:45:27 +01:00
parent c23e2eb1f6
commit 11ec445164
1 changed files with 16 additions and 0 deletions

View File

@ -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] #[test]
fn test_log() { fn test_log() {
log_debug!("log_test", "debug msg"); log_debug!("log_test", "debug msg");