| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <49FFC04E.7010601@gmail.com> |
| Date: | Tue, 05 May 2009 05:27:58 +0100 |
| From: | Dave Korn <dave DOT korn DOT cygwin AT googlemail DOT com> |
| User-Agent: | Thunderbird 2.0.0.17 (Windows/20080914) |
| MIME-Version: | 1.0 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: problems using Xlib.h/Xwindows.h/unistd.h and win32api under gcc-4 |
| References: | <c342c1150905041957q448e21f5nffbd6200666425ab AT mail DOT gmail DOT com> |
| In-Reply-To: | <c342c1150905041957q448e21f5nffbd6200666425ab@mail.gmail.com> |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
Chris LeBlanc wrote:
>> gcc-4 test_sleep.c -Wall -lX11 -lcomdlg32 -o test_sleep
> In file included from /usr/include/unistd.h:4,
> from test_sleep.c:4:
> /usr/include/sys/unistd.h:144: error: expected declaration specifiers
> or '...' before '(' token
> /usr/include/sys/unistd.h:144: error: conflicting types for 'Sleep'
> /usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../include/w32api/winbase.h:1984:
> error: previous declaration of 'Sleep' was here
Argh. Someone somewher has done "#define sleep Sleep" and it's messing over
the definition of sleep() in unistd.h making it conflict with Sleep() from
winbase.h. No, hang on, it's even worserer than that:
# 69 "/usr/include/X11/Xwindows.h" 3 4
#define sleep(x) Sleep((x) * 1000)
... leading to this nonsensical declaration:
unsigned __attribute__((__cdecl__)) Sleep((unsigned int __seconds) * 1000);
Ok, so you can work around that with careful ordering, as long as you don't
want the unistd version of sleep. Try it like this:
admin AT ubik /tmp/x
$ cat test-x.c
#include <stdio.h>
#include <unistd.h>
#include <X11/Xwindows.h>
#include <windows.h>
int main() {
printf("Hello\n");
return 0;
}
admin AT ubik /tmp/x
$ gcc-4 test-x.c -Wall -lX11 -lcomdlg32 -o test-x.exe --save-temps
admin AT ubik /tmp/x
$ ./test-x.exe
Hello
admin AT ubik /tmp/x
$
cheers,
DaveK
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |