I have a kevent ev
and a int sock = socket(...)
. When I did ev.ident == sock
, the g++47 warned me that warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
. What's wrong in my approach??
If you check the type, it's of type uintptr_t
which is a standard type big enough to hold both the largest integer or a pointer. This is so it can be used on any kind of type which can easily be casted as an integer. And from the FreeBSD kqueue manual page:
Value used to identify this event. The exact interpretation is determined by the attached filter, but often is a file descriptor.
So I would definitely say it's by design.
If you want to get rid of the warning, I suggest yo cast the socket:
ev.ident == static_cast<uintptr_t>(sock)