Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update cast to modern style #418

Merged
merged 3 commits into from
Mar 28, 2023
Merged
Changes from 2 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
9 changes: 8 additions & 1 deletion resource/logging_macros.h.em
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
#include <stdio.h>
#include <stdlib.h>

// This is to avoid compilation warnings in C++ with '-Wold-style-cast'.
#ifdef __cplusplus
#define CAST_DURATION(x) (static_cast < rcutils_duration_value_t > (x))
clalancette marked this conversation as resolved.
Show resolved Hide resolved
#else
#define CAST_DURATION(x) ((rcutils_duration_value_t)x)
#endif

#ifdef __cplusplus
extern "C"
{
Expand Down Expand Up @@ -174,7 +181,7 @@ typedef bool (* RclLogFilter)();
* A macro initializing and checking the `throttle` condition.
*/
#define RCUTILS_LOG_CONDITION_THROTTLE_BEFORE(get_time_point_value, duration) { \
static rcutils_duration_value_t __rcutils_logging_duration = RCUTILS_MS_TO_NS((rcutils_duration_value_t)duration); \
static rcutils_duration_value_t __rcutils_logging_duration = RCUTILS_MS_TO_NS(CAST_DURATION(duration)); \
static rcutils_time_point_value_t __rcutils_logging_last_logged = 0; \
rcutils_time_point_value_t __rcutils_logging_now = 0; \
bool __rcutils_logging_condition = true; \
Expand Down