On Thu, Jan 23, 2020 at 12:24:19PM +0100, Tim Düsterhus wrote:
> Willy,
>
> Am 23.01.20 um 10:56 schrieb Willy Tarreau:
> >> I've using clang during the testing, and apparently -Wextra doesn't enable
> >> it on clang (I'm using v9.0), only -pedantic helps:
> >>
> >> clang -Wall -Wextra -Wpedantic test.c
> >>
> >> test.c:6:12: warning: ordered comparison between pointer and zero ('char *'
> >> and 'int') is an extension [-Wpedantic]
> >
> > Ah that's interesting, because from a semantic perspective there is no
> > reason to compare an int and a pointer, given that an int is a distance
> > between two pointers (divided by the element's size), so being able to
>
> Not to disgress too much, but isn't `ptrdiff_t` from `stddef.h` the
> distance between two pointers? :-)
Yes, it's just an alias for whatever integer applies to your platform
(i.e. int or long basically). Unless you're on Windows which is LLP64,
long is almost always OK.
Willy