delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/05/04/22:58:03

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=2.0 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Date: Tue, 5 May 2009 14:57:47 +1200
Message-ID: <c342c1150905041957q448e21f5nffbd6200666425ab@mail.gmail.com>
Subject: problems using Xlib.h/Xwindows.h/unistd.h and win32api under gcc-4
From: Chris LeBlanc <crleblanc AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
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

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019