Den onsdag 30 mars 2016 kl. 05:42:39 UTC+2 skrev Richard Levitte:
> Compiling the following test program fails miserably:
>
> ---------- 8< [snip] ----------
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <netdb.h>
>
> int main()
> {
> struct addrinfo *res = NULL;
> int ret;
>
> ret = getaddrinfo("localhost", "http", NULL, &res);
> freeaddrinfo(res);
> }
> ---------- 8< [snip] ----------
>
> Here's how it compiles:
>
> $ cc /pointer_size=64 foo.c
>
> ret = getaddrinfo("localhost", "http", NULL, &res);
> ..........^
> %CC-W-PTRMISMATCH, In this statement, the referenced type of the pointer value "&res" is "long pointer to struct addrinfo", which is not compatible with "long pointer to struct __addrinfo64".
> at line number 10 in file USER:[LEVITTE]FOO.C;2
>
> freeaddrinfo(res);
> ....^
> %CC-W-PTRMISMATCH, In this statement, the referenced type of the pointer value "res" is "struct addrinfo", which is not compatible with "struct __addrinfo64".
> at line number 11 in file USER:[LEVITTE]FOO.C;2
>
>
> Does anyone have a *sensible* workaround?
The workaround was too easy...
$ diff sys$login:foo.c
************
File USER:[LEVITTE]FOO.C;3
5 #if __INITIAL_POINTER_SIZE == 64
6 # define addrinfo __addrinfo64
7 #endif
8
9 int main()
******
File USER:[LEVITTE]FOO.C;2
5 int main()
************
> Also, this is really a bug in netdb.h (it doesn't restore pointer size prior to defining 'struct addrinfo'), who can I pester to file a bug report?
Still, netdb.h needs fixing.
Also, if anyone wonders:
$ cc/vers
HP C V7.3-010 on OpenVMS Alpha V8.4
Cheers,
Richard