Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6347

SDK • Re: Trouble printing time_us_64() [SOLVED]

$
0
0
Adding '-Werror' and/or '-Wall' - I have no recollection of which works, GCC will usually warn when the incorrect format for the variable is given and, best of all, tells you what it should be -

Code:

/home/pi/mypico/timing/timing.c:25:20: error: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]   25 |           printf("%u\n", time_us_64());      |                   ~^     ~~~~~~~~~~~~      |                    |     |      |                    |     uint64_t {aka long long unsigned int}      |                    unsigned int      |                   %llu
And that also justifies why "%llu", though I am not sure why C couldn't have adopted "%u64" or something similar, even a full "%uint64_t".

Statistics: Posted by hippy — Wed Jan 01, 2025 7:49 pm



Viewing all articles
Browse latest Browse all 6347

Trending Articles