fgouget at free.fr
Tue Nov 20 11:23:28 CST 2001
On Tue, 20 Nov 2001 lawson_whitney at juno.com wrote:
> Good day!
> To try debugging techniques for winelib apps, I had in mind to make a
> winelib app with an intentional segment fault, and found that _my_
> winelib app will no longer compile. (gcc-2.95.3, glibc-2.2.3, current
> wine CVS). Please, it needs unistd.h so it can comfortably log to
> syslog. running winemaker on it again didn't help.
Note that 'unistd.h' does not exist on Windows. So this Winelib app
is no longer portable and this is why you are having trouble. Do you
really need to log to syslog in a test application? Wouldn't it be
simpler to just write to stderr, or fprintf(log_file,...)'? Then
you can simply #include 'stdio.h' which will work with the winsock
headers and also compile on Windows.
> [whit at giftie wlp]$ make
> gcc -c -g -O2 -fPIC -D_REENTRANT -DWINELIB -I. -I/usr/local/include/wine -o t
> oj2.o toj2.c
> In file included from /usr/local/include/wine/winsock2.h:30,
> from /usr/local/include/wine/windows.h:39,
> from toj2.h:29,
> from toj2.c:19:
> /usr/local/include/wine/winsock.h:886: conflicting types for `gethostname'
> /usr/include/unistd.h:734: previous declaration of `gethostname'
> make: *** [toj2.o] Error 1
> [whit at giftie wlp]$
Ok. The other reason why it does not work is that I did no realize
that 'unistd.h' was defining 'gethostname'. The reason for that being
that I tested the new headers with Wine and real Windows applications
that of course don't include 'unistd.h'.
I had a similar problem with 'stdlib.h' though. So you can look at
'winsock.h' to see how I dealt with it. I am not sure whether it is
worth putting similar code in winsock.h for unistd.h: it would force us
to #include unistd.h in winsock.h which would pollute the namespace for
all Winelib application although no regular Windows application is
supposed to use that header.
You can also deal with unistd.h in your own application by doing:
#define gethostname linux_gethostname
And making sure that unistd.h is included before winsock.h.
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
f u kn rd ts, ur wy 2 gky 4 ur wn gd.
More information about the wine-devel