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

Chris LeBlanc crleblanc@gmail.com
Tue May 5 02:57:00 GMT 2009


Hi,

I'm trying to migrate our commercial software (we've purchased a
commercial Cygwin license) thats been running well on Cygwin using gcc
3.x to gcc-4.  Its mature Unix/Linux C and Fortran code.  We're using
the win32api so we can use native Windows file dialogs.  This has been
working in gcc 3.4, but now raises an error with gcc 4.3.2 (updated
Cygwin yesterday).  I've narrowed this down with a bit of example
code:


#include <stdio.h>
/* The next two includes have conflicts: */
#include <X11/Xlib.h>
#include <windows.h>
/* so do these two: */
//#include <X11/Xwindows.h>
#include <unistd.h>

int main() {
    printf("Hello\n");
    return 0;
}



This ultra-simple program includes <X11/Xlib.h>, <windows.h>
(win32api), and unistd.h.  I gave gcc-4 the flags -lX11 for X11
libraries, and -lcomdlg32 for the Windows dialog libraries. Here is
the error I see:

> gcc-4 test_sleep.c -Wall -lX11 -lcomdlg32 -o test_sleep
In file included from
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../include/w32api/windows.h:87,
                 from test_sleep.c:5:
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../include/w32api/winspool.h:255:
error: two or more data types in declaration specifiers
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../include/w32api/winspool.h:270:
error: two or more data types in declaration specifiers
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../include/w32api/winspool.h:291:
error: two or more data types in declaration specifiers
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../include/w32api/winspool.h:316:
error: two or more data types in declaration specifiers
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../include/w32api/winspool.h:571:
error: two or more data types in declaration specifiers
/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../../include/w32api/winspool.h:594:
error: two or more data types in declaration specifiers



I noticed this post:
http://sourceware.org/ml/cygwin/2009-03/msg00420.html, so tried
replacing <X11/Xlib.h> with <X11/Xwindows.h>.  This now raises a
different error, this time conflicting with unistd.h.  If we also
comment out the include for windows.h, we still get the same error:

> 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



So in summary, X11/Xlib.h conflicts with windows.h, and X11/Xwindow.h
conflicts with unistd.h.

Any suggestions on how to get around this (unfortunately I need
unistd.h, windows.h, and either Xlib.h or Xwindows.h)?  The fact that
Xwindows.h conflicts with unistd.h (a common scenario) suggests a bug
in Xwindows.h, unfortunately I'm not sure how to fix the problem.

Cheers,
Chris

--
Chris LeBlanc
Claritas Development
GNS Science
Lower Hutt, New Zealand
Web: www.globeclaritas.com

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



More information about the Cygwin mailing list