[ 
https://issues.apache.org/jira/browse/DISPATCH-1669?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17114728#comment-17114728
 ] 

Jiri Daněk commented on DISPATCH-1669:
--------------------------------------

Because uint64_t is commonly defined either as {{unsigned long int}} or 
{{unsigned long long int}}, the printf format specifier must change according 
to the underlying type, or there must be a cast.

In C99, the way to achieve the first is the PRIu64 macro. It looks quite ugly, 
but that's what it is.

Alternatively, the value could be cast to {{unsigned long long}}, which is 
guaranteed to be a 64bit type, prior to printing it. This does not look all 
that pretty either.

This issue would (probably) also affect 32 bit systems, where it IMO also makes 
sense to define unit65_t as unsigned long long, but I did not check that.

> Compilation fails on macOS [-Werror,-Wformat]
> ---------------------------------------------
>
>                 Key: DISPATCH-1669
>                 URL: https://issues.apache.org/jira/browse/DISPATCH-1669
>             Project: Qpid Dispatch
>          Issue Type: Bug
>            Reporter: Jiri Daněk
>            Assignee: Jiri Daněk
>            Priority: Major
>              Labels: macOS
>
> https://travis-ci.org/github/apache/qpid-dispatch/jobs/690194590
> {noformat}
> [  1%] Building C object tests/CMakeFiles/clogger.dir/clogger.c.o
> /Users/travis/build/apache/qpid-dispatch/tests/clogger.c:430:64: error: format
>       specifies type 'long' but the argument has type 'uint64_t' (aka
>       'unsigned long long') [-Werror,-Wformat]
>         printf("Sent: %ld  Accepted: %ld Not Accepted: %ld\n", sent, acc...
>                       ~~~                                      ^~~~
>                       %llu
> /Users/travis/build/apache/qpid-dispatch/tests/clogger.c:430:70: error: format
>       specifies type 'long' but the argument has type 'uint64_t' (aka
>       'unsigned long long') [-Werror,-Wformat]
>         printf("Sent: %ld  Accepted: %ld Not Accepted: %ld\n", sent, 
> accepted, n...
>                                      ~~~                             ^~~~~~~~
>                                      %llu
> /Users/travis/build/apache/qpid-dispatch/tests/clogger.c:430:80: error: format
>       specifies type 'long' but the argument has type 'uint64_t' (aka
>       'unsigned long long') [-Werror,-Wformat]
>   ...%ld  Accepted: %ld Not Accepted: %ld\n", sent, accepted, not_accepted);
>                                       ~~~                     ^~~~~~~~~~~~
>                                       %llu
> /Users/travis/build/apache/qpid-dispatch/tests/clogger.c:432:56: error: format
>       specifies type 'long' but the argument has type 'uint64_t' (aka
>       'unsigned long long') [-Werror,-Wformat]
>             printf("FAILURE! Sent: %ld  Acked: %ld\n", sent, accepted + ...
>                                    ~~~                 ^~~~
>                                    %llu
> /Users/travis/build/apache/qpid-dispatch/tests/clogger.c:432:62: error: format
>       specifies type 'long' but the argument has type 'unsigned long long'
>       [-Werror,-Wformat]
>   ...Sent: %ld  Acked: %ld\n", sent, accepted + not_accepted);
>                        ~~~           ^~~~~~~~~~~~~~~~~~~~~~~
>                        %llu
> 5 errors generated.
> {noformat}
> {noformat}
> [ 72%] Building C object 
> src/CMakeFiles/qpid-dispatch.dir/http-libwebsockets.c.o
> /Users/travis/build/apache/qpid-dispatch/src/http-libwebsockets.c:620:110: 
> error: 
>       format specifies type 'unsigned long' but the argument has type 
> 'uint64_t'
>       (aka 'unsigned long long') [-Werror,-Wformat]
>   ...end - *position, "%s:%s_bytes %lu\n", name, field.name, field.value);
>                                    ~~~                       ^~~~~~~~~~~
>                                    %llu
> 1 error generated.
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to