This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problems using Xlib.h/Xwindows.h/unistd.h and win32api under gcc-4


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@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@ubik /tmp/x
$ gcc-4 test-x.c  -Wall -lX11 -lcomdlg32 -o test-x.exe --save-temps

admin@ubik /tmp/x
$ ./test-x.exe
Hello

admin@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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]