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 <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois 2015-05-19 11:04:39 -07:00
parent e2d175b3e5
commit ce96329f95
2 changed files with 9 additions and 5 deletions

View File

@ -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());

View File

@ -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
*/