From ce96329f954bf722a26a1f504c8bc51d6bedcf4a Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Tue, 19 May 2015 11:04:39 -0700 Subject: [PATCH] Resolve printing uint64 types Using %llu or %lu will break one of the build targets. The "right way" to print a uint64_t is via the PRIU64 macro defined in C99. This wasn't defined for the NuttX compiler so it was added to px4_defines.h for NuttX. Signed-off-by: Mark Charlebois --- src/examples/subscriber/subscriber_example.cpp | 10 +++++----- src/platforms/px4_defines.h | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/examples/subscriber/subscriber_example.cpp b/src/examples/subscriber/subscriber_example.cpp index c4af0757b5..77bfcb8d3e 100644 --- a/src/examples/subscriber/subscriber_example.cpp +++ b/src/examples/subscriber/subscriber_example.cpp @@ -45,7 +45,7 @@ using namespace px4; void rc_channels_callback_function(const px4_rc_channels &msg) { - PX4_INFO("I heard: [%lu]", msg.data().timestamp_last_valid); + PX4_INFO("I heard: [%" PRIu64 "]", msg.data().timestamp_last_valid); } SubscriberExample::SubscriberExample() : @@ -84,21 +84,21 @@ SubscriberExample::SubscriberExample() : */ void SubscriberExample::rc_channels_callback(const px4_rc_channels &msg) { - PX4_INFO("rc_channels_callback (method): [%lu]", + PX4_INFO("rc_channels_callback (method): [%" PRIu64 "]", msg.data().timestamp_last_valid); - PX4_INFO("rc_channels_callback (method): value of _sub_rc_chan: [%lu]", + PX4_INFO("rc_channels_callback (method): value of _sub_rc_chan: [%" PRIu64 "]", _sub_rc_chan->data().timestamp_last_valid); } void SubscriberExample::vehicle_attitude_callback(const px4_vehicle_attitude &msg) { - PX4_INFO("vehicle_attitude_callback (method): [%lu]", + PX4_INFO("vehicle_attitude_callback (method): [%" PRIu64 "]", msg.data().timestamp); } void SubscriberExample::parameter_update_callback(const px4_parameter_update &msg) { - PX4_INFO("parameter_update_callback (method): [%lu]", + PX4_INFO("parameter_update_callback (method): [%" PRIu64 "]", msg.data().timestamp); _p_sub_interv.update(); PX4_INFO("Param SUB_INTERV = %d", _p_sub_interv.get()); diff --git a/src/platforms/px4_defines.h b/src/platforms/px4_defines.h index f350a26326..db54f8c53e 100644 --- a/src/platforms/px4_defines.h +++ b/src/platforms/px4_defines.h @@ -105,6 +105,10 @@ typedef param_t px4_param_t; #define PX4_ISFINITE(x) isfinite(x) +#ifndef PRIu64 +#define PRIu64 "llu" +#endif + /* * POSIX Specific defines */