delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/05/13/03:56:51

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:references
:in-reply-to:content-type:mime-version
:content-transfer-encoding; q=dns; s=default; b=OvC0Pm2k+QvLGTyR
KhwHiJ5JaXlC/niG68KK/kIRSnYpbj8Tcd4GNm7dX6NH/POSH10EaLOzjsfcLu3+
au7eSUXGXuxg7KNxwKrN+RsrL2/AUUefcZf6zUwPFwky+8yX6Pfty6fPMWn/fBZd
D7nkJUnm2PQ2hqRMvsDreUlBvDs=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:references
:in-reply-to:content-type:mime-version
:content-transfer-encoding; s=default; bh=OUz3I9hKVgfO3vSQ4kRCqe
DqVeg=; b=rIOeySWA/pIU2tCstZUoTPDrXnYmcfn4pA3taXAM3xJ42vuiNHHhRv
NogicwrdmWSY7F0G4cb1PjQwPBhIXuS6WZzrzFi5MvOJnBelaSnQsUMPzzo+fxNT
/YixS7wHvA0S1VAHiSQ9lmczOH2PhWTQFfFWaxwv2Nri5+mDvTVx8=
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
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,MIME_BASE64_BLANKS,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=vice, Managing, directors, michael
X-HELO: mga12.intel.com
From: "Soegtrop, Michael" <michael DOT soegtrop AT intel DOT com>
To: Agner Fog <agner AT agner DOT org>, "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: RE: Why is __unix__ defined, and not __WINDOWS__ ?
Date: Mon, 13 May 2019 07:54:23 +0000
Message-ID: <0F7D3B1B3C4B894D824F5B822E3E5A178FD6D132@IRSMSX102.ger.corp.intel.com>
References: <5fbb6229-da17-c056-19b9-9819c684a8ad AT agner DOT org> <8e9bfbb4-2139-639d-afaa-dfbacac1a8d9 AT t-online DOT de> <dfd043fb-620a-81a1-1611-91a982fc96cd AT agner DOT org>
In-Reply-To: <dfd043fb-620a-81a1-1611-91a982fc96cd@agner.org>
MIME-Version: 1.0
X-IsSubscribed: yes
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id x4D7unUv021055

Dear Agner,

> But the compiler generates a Windows executable following most of the
> Windows ABI (object file format, calling convention, etc.)

Still cygwin is intentionally very different from Windows, e.g. on Cygwin you use / as path separator, on Windows you use \ as path separator. Cygwin console executables produce \n line endings, MinGW produce \r\n line endings. Cygwin executables go through path translation (C:\ is /cygdrive/c/) ... Many C programs will consult __WINDOWS__ to find out what the path separator should be and this would go wrong if cygwin gcc would define __WINDOWS__. I would see Cygwin as a lightweight Posix virtual environment on Windows. If you run gcc on the Linux Subsystem for Windows you also wouldn't expect it to define __WINDOWS__. In a sense the reason Cygwin exists is that it has a gcc which defined __unix__.

As was mentioned before, if you goal is to create Windows ABI compatible binaries, you should use the MinGW cross compiler, which is available as package for Cygwin (mingw64-x86_64-... ). Please note that you should use a 64 bit cygwin to create 64 bit binaries and a 32 bit Cygwin to create 32 bit binaries. This is because the Windows filesystem has a hack that 32 and 64 bit DLLs have the same filename and which one you get depends on if you are a 32 bit or 64 bit executable. So 64 bit linker which is a 32 bit executable trying to create a 64 bit binary would see the wrong DLLs and vice versa.

Another option is to use a MinGW, MSys or MSys2 distribution - I personally prefer Cygwin exactly because it does this stricter separation between a Posix world and a Windows world. But if you main goal is to have a gcc for Windows, Cygwin might not be the best choice for you.

Best regards,

Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


- Raw text -


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