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: 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 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" To: Agner Fog , "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> In-Reply-To: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-IsSubscribed: yes Content-Transfer-Encoding: 8bit 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