On Sat, Jan 5, 2019 at 7:25 PM Adam Steen <a...@adamsteen.com.au> wrote:

> I have a question about string (printf) formatting.
>
> I have a variable
>
> 'uint64_t freq'
>
> which is printed with
>
> 'log(DEBUG, "Solo5: clock_init(): freq=%lu\n", freq);'
>
> but am getting the following error
>
> '
> error: format specifies type 'unsigned long' but the argument has type
> 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
>         freq);
>         ^~~~~~~~
> 1 error generated.
> '
>
> The easy fix is to change the format to '%llu', but this brakes FreeBSD
> and Linux. Am i missing something or should i be investigating the log
> implementation?
>

Option 1)
    log(DEBUG, "Solo5: clock_init(): freq=%llu\n", (unsigned long
long)freq);

Option 2)
    #include <inttypes.h>
    log(DEBUG, "Solo5: clock_init(): freq=%"PRIu64"\n", freq);

Software native to OpenBSD uses option 1 when necessary.


Philip Guenther

Reply via email to