On Wed, May 18, 2011 at 2:31 PM, Dimitry Andric <d...@freebsd.org> wrote: > On 2011-05-18 23:16, Pawel Jakub Dawidek wrote: >> >> On Wed, May 18, 2011 at 09:06:20PM +0000, Ben Laurie wrote: >>> >>> Author: benl >>> Date: Wed May 18 21:06:20 2011 >>> New Revision: 222084 >>> URL: http://svn.freebsd.org/changeset/base/222084 >>> >>> Log: >>> Fix clang warnings. >>> >>> Approved by: philip (mentor) >> >> [...] >>> >>> - fprintf (stderr, " by changing asso_value['%c'] (char #%d) >>> to %d\n", >>> + fprintf (stderr, " by changing asso_value['%c'] (char #%zd) >>> to %d\n", >>> *p, p - union_set + 1, asso_values[(unsigned >>> char)(*p)]); >> >> Hmm, both 'p' and 'union_set' are 'char *' and %zd is for ssize_t. It is >> a bit strange that it fixes the warning. > > If you subtract two pointers, such as in this case, you get a ptrdiff_t. > > Strictly, this doesn't have to be exactly the same type as ssize_t, but > in practice it will almost always be. > > You can also cast the result to intmax_t, and use %jd, then it will > always be correct, but possibly have some small overhead.
Or you can use %td which is the C99 conversion specifier for ptrdiff_t. Thanks, matthew _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"