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 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: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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 #include #include #include 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/