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.
checking for wrc... /usr/local/bin/wrc updating cache ./config.cache creating ./config.status creating Make.rules creating Makefile creating launcher
Configure finished. Do 'make' to build the project.
[whit@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@giftie wlp]$
I would be glad of a bit of advice thanks,
Lawson
Constants aren't, and variables won't.
On Tue, 20 Nov 2001 lawson_whitney@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@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@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 #include <unistd.h> #undef gethostname
And making sure that unistd.h is included before winsock.h.
-- Francois Gouget fgouget@free.fr http://fgouget.free.fr/ f u kn rd ts, ur wy 2 gky 4 ur wn gd.
On Tue, 20 Nov 2001, Francois Gouget wrote:
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.
I didn't say that very well, I guess. The program that wants unistd.h functions in my mail system as a linux sendmail. I don't really care if it is portable to windows, it only uses windows functions to manipulate storage objects. I guess it would have more mass appeal if I would port it to windows, but I don't know how. Does windows even have a sendmail? A home directory for each user? That just happened to be the program I picked to tinker with, which is how I found it doesn't compile anymore. Right, windows compatibility is enough of a challenge for the wine headers, I don't mean to give you more problems. What I like about winelib is you can use windows functions without being enslaved by that whole ugly API. :-)
[...]
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.
Probably not. I think if I want to use unix functions in winelib apps, I should be willing to dodge the namespace collisions.
You can also deal with unistd.h in your own application by doing:
#define gethostname linux_gethostname #include <unistd.h> #undef gethostname
And making sure that unistd.h is included before winsock.h.
That looks simple enough. I'll try that, I think. Thanks!
-- Francois Gouget fgouget@free.fr http://fgouget.free.fr/ f u kn rd ts, ur wy 2 gky 4 ur wn gd.
Lawson
| We apologize if this message has reached you in error. | Save the Planet, Save the Trees! Advertise via E mail.
On Tue, 20 Nov 2001 lawson_whitney@juno.com wrote: [...]
You can also deal with unistd.h in your own application by doing:
#define gethostname linux_gethostname #include <unistd.h> #undef gethostname
And making sure that unistd.h is included before winsock.h.
That looks simple enough. I'll try that, I think. Thanks!
There is also another way, in case you don't use winsock in your application: define WINE_NOWINSOCK and then 'windows.h' will not #include 'winsock2.h'. This should also solve the name collision.
There is even yet another way to handle this: define USE_WS_PREFIX and then all name collisions will be avoided. This will even let you use both the Unix and Windows sockets though using the winsock functions will probably be a bit hard. And that's probably not really what you want to do anyway.
-- Francois Gouget fgouget@free.fr http://fgouget.free.fr/ "Utilisateur" (nom commun) : Mot utilisé par les informaticiens en lieu et place d'"idiot".
On Tue, 20 Nov 2001, Francois Gouget wrote:
#define gethostname linux_gethostname #include <unistd.h> #undef gethostname
Okay, it now compiles. If you get this letter, it works, too 8-D
-- Francois Gouget fgouget@free.fr http://fgouget.free.fr/ f u kn rd ts, ur wy 2 gky 4 ur wn gd.
Thanks!
Lawson
Fight fire with water, but cold is the greater evil. - Proverbs of Hell Revisited ---cut here
________________________________________________________________ GET INTERNET ACCESS FROM JUNO! Juno offers FREE or PREMIUM Internet access for less! Join Juno today! For your FREE software, visit: http://dl.www.juno.com/get/web/.