[mw-devel] Weird error compiling mw in c99 mode

Peter Berry pwb at sucs.org
Tue Mar 21 02:42:22 GMT 2006


[pwb at silver src]$ make
gcc -DBUILD_DATE=\"20060321\" -DBUILD_USER=\"Pwb\" -DVER_MAJ=\"2\" 
-DVER_MIN=\"14\" -DVER_TWK=\"0\" -DHOMEPATH=\"/home/life/pwb/src/mymw\" 
-O4 -DRELEASE -Wall -pedantic -fpie -std=c99 -D_GNU_SOURCE -c main.c
main.c: In function `main':
main.c:565: error: incompatible type for argument 2 of `getpeername'
make: *** [main.o] Error 1


Note that I've added -std=c99 and -D_GNU_SOURCE to CFLAGS. Here's the 
offending code:

                 struct sockaddr sa;
                 socklen_t ss;

                 ss=sizeof(sa);
                 /* can we log a hostname ? */
                 if (getpeername(fileno(stdin), &sa , &ss))
                         mwlog("LOGIN");


So obviously &sa is a struct sockaddr *, and &ss is a socklen_t * (but is 
an int * in cvs). Here's the prototype given in the manpage:

int getpeername(int s, struct sockaddr *name, socklen_t *namelen);

And the actual declaration in sys/socket.h:

extern int getpeername (int __fd, __SOCKADDR_ARG __addr,
                         socklen_t *__restrict __len) __THROW;

So, as far as I can tell, arg 2 (&sa) is of the correct type, but gcc 
disagrees. What's going on here? The preprocessor appears not to process 
__SOCKADDR_ARG so it must be typedef'd somewhere, but I can't find 
anything in the headers.

-- 
Peter Berry, SUCS Ex-Treasurer
<pwb at sucs.org>



More information about the mw-devel mailing list