[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RE : [lwip-users] LWIP_COMPAT_SOCKETS in sockets.h

From: Kieran Mansley
Subject: Re: RE : [lwip-users] LWIP_COMPAT_SOCKETS in sockets.h
Date: Wed, 06 Sep 2006 16:35:21 +0100

On Wed, 2006-09-06 at 17:13 +0200, Frédéric BERNON wrote:
> Hi Kieran,
> Yes, read, write and close are usually used for files in "unistd.h".
> So, if in a same code, you have to use files and sockets, there is a
> problem. You got compilation errors like : 
> "...\include\unistd.h (89) : error: declaration is incompatible with
> "int lwip_write(int, void *, int)" (declared at line 256 of "C:\lwip
> \sockets.h") "

Yes, I understand the compile error - that's why we have the
LWIP_COMPAT_SOCKETS option.  I was trying to work out why you'd want to
define LWIP_COMPAT_SOCKETS and not have read, write, and close renamed,
but looks like it is because those are used for things other than

Seems like you have a fairly sensible solution to your problem, but I
wonder what will happen when your code that uses both files and sockets
calls read or write or close on a socket rather than file?  I assume you
must have manually modified the application to not use read, write or
close for sockets, and to use lwip_read etc directly instead.

I worry that with a simple compile time option to get rid of the errors
as you suggest, others using the code might not realise that there is a
problem that they need to modify the application to solve.  i.e. You've
effectively replaced a fairly easy to debug compile error with a rather
more difficult to debug run time error.

e.g. If I have a simple app along the lines of (pseudo-code):

#include <unistd.h>
#include <lwip_sockets.h>
fd = open(); //a file descriptor
sock = socket(); //a socket

I try to compile with lwip (with LWIP_COMPAT_SOCKET=1 and
LWIP_IO_SOCKETS=1) and I'll get the compile error alerting me that I've
got a problem (mixed use of file descriptors and sockets).  However, if
I then saw the LWIP_IO_SOCKETS option, I might try with that turned off.
It would now compile fine using the definitions of read, write and close
from unistd.h, but when I came to run it I'd be rather confused about
why the write() call didn't work.

Hope that makes sense!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]