mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 05:53:34 +08:00
Linux: in printf cast uint64_t to unsigned long long
When printing a uint64_t type using %llu, this works on a 32bit system, but on a 64bit machine uint64_t is an unsigned long. The compiler complains about unmatching types. The time times in PX4 should likely have been unsigned long long and not uint64_t as that type changes per architecture. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -1657,7 +1657,7 @@ Mavlink::display_status()
|
||||
{
|
||||
|
||||
if (_rstatus.heartbeat_time > 0) {
|
||||
printf("\tGCS heartbeat:\t%llu us ago\n", hrt_elapsed_time(&_rstatus.heartbeat_time));
|
||||
printf("\tGCS heartbeat:\t%llu us ago\n", (unsigned long long)hrt_elapsed_time(&_rstatus.heartbeat_time));
|
||||
}
|
||||
|
||||
printf("\tmavlink chan: #%u\n", _channel);
|
||||
|
||||
@@ -53,14 +53,14 @@ int HRTTest::main()
|
||||
hrt_abstime t = hrt_absolute_time();
|
||||
usleep(1000000);
|
||||
hrt_abstime elt = hrt_elapsed_time(&t);
|
||||
printf("Elapsed time %llu in 1 sec (usleep)\n", elt);
|
||||
printf("Start time %llu\n", t);
|
||||
printf("Elapsed time %llu in 1 sec (usleep)\n", (unsigned long long)elt);
|
||||
printf("Start time %llu\n", (unsigned long long)t);
|
||||
|
||||
t = hrt_absolute_time();
|
||||
sleep(1);
|
||||
elt = hrt_elapsed_time(&t);
|
||||
printf("Elapsed time %llu in 1 sec (sleep)\n", elt);
|
||||
printf("Start time %llu\n", t);
|
||||
printf("Elapsed time %llu in 1 sec (sleep)\n", (unsigned long long)elt);
|
||||
printf("Start time %llu\n", (unsigned long long)t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user