[Privoxy-devel] incompatible pointer type

Fabian Keil fk at fabiankeil.de
Wed Jan 9 14:32:19 UTC 2019


Lee <ler762 at gmail.com> wrote:

> All pointers are the same size - correct?

Correct.

> I get a couple of warnings in jbsockets.c about incompatible pointer types - eg:
> jbsockets.c: In function ‘set_no_delay_flag’:
> jbsockets.c:140:49: warning: passing argument 4 of ‘setsockopt’ from
> incompatible pointer type [-Wincompatible-pointer-types]
>     if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof(int)))
>                                                  ^
> In file included from jbsockets.c:52:0:
> /usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h:999:34: note:
> expected ‘const char *’ but argument is of type ‘int *’
>    WINSOCK_API_LINKAGE int WSAAPI setsockopt(SOCKET s,int level,int
> optname,const char *optval,int optlen);
>                                   ^~~~~~~~~~
> 
> that boils down to Windows expects a 'char*' pointer & *nix expects a
> 'int*' pointer.

On ElectroBSD the prototype is:

     int
     setsockopt(int s, int level, int optname, const void *optval,
         socklen_t optlen);
 
> I can make the warnings go away by casting the 4th parameter to (char*)
> -   if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof(int)))
> +   if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&mi, sizeof(int)))
> 
> but a 'char*' pointer is the same size as an 'int*' pointer, so this
> is just a cosmetic issue that can safely be ignored.  Correct?

Correct.

Fabian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.privoxy.org/pipermail/privoxy-devel/attachments/20190109/cdc3fc4c/attachment.bin>


More information about the Privoxy-devel mailing list