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:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=Gr0I+0xRUKFWLgmE k6W+hKmw6vtvpANcggtWK7WOekBlW0DKlZcxGxAUj2uuDj9zGmOzxiK/39yZewc6 yfHUBV1w0TwaR6+6RAqXS5UXgm57kavu48OCjN7am4pAEdDIR7wRka475Cfd8Hbr rlw9UG2pQ5e6daS+BBVn60CgtQM= 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:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=eTkytY+QbdgpE4v6Yk4BZp 26VEA=; b=s02CUD4X9pmdn4Qlt5yrHtHEMcEXFfIwACMK5m5d3VdkdHYUeBZcQp T7f1Dfv/KuU3rTRsszmQWcUYYSvnKkigsp97zZsOzt9l5ZgZhBj3VTLVzgxqNOFt 0u/UhoYcg/SGj0uKSfc/6uuVuwHRzoV9lZq+UoOkPjRGpK75JmNFw= 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=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=no, 21.53, Posix, 2153 X-HELO: smtp-out-so.shaw.ca Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca Subject: Re: Why is __unix__ defined, and not __WINDOWS__ ? To: cygwin AT cygwin DOT com References: <5fbb6229-da17-c056-19b9-9819c684a8ad AT agner DOT org> <8e9bfbb4-2139-639d-afaa-dfbacac1a8d9 AT t-online DOT de> From: Brian Inglis Openpgp: preference=signencrypt Message-ID: <72c5e82b-38f0-8701-93fe-5682176017b6@SystematicSw.ab.ca> Date: Sun, 12 May 2019 23:39:58 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes On 2019-05-12 22:12, Agner Fog wrote: > On 12/05/2019 21.53, Hans-Bernhard Bröker wrote: >> Am 12.05.2019 um 20:22 schrieb Agner Fog: >>> I have noticed that the gcc and clang compilers have defined the >>> preprocessing macro __unix__, but not __WINDOWS__, _WIN32, or _WIN64 >>> when compiling a windows executable. >>> Why is this? >> Because it's correct that way.  Cygwin runs on Windows, but it _is_ not >> Windows. >>> A C/C++ program will check for these macros if it wants to know which >>> operating system you are compiling for, and this will give the wrong >>> result. >> No.  It gives the correct result.> But the compiler generates a Windows executable following most of the > Windows ABI (object file format, calling convention, etc.) Not quite I believe Cygwin 64 bit programs follow the Unix 64 bit LP64 C programming memory model and the System V AMD64 ABI *NOT* the Windows 64 bit ILP64 C programming memory model and Microsoft x64 calling convention; see: http://www.unix.org/version2/whatsnew/lp64_wp.html https://en.wikipedia.org/wiki/X86_calling_conventions - the interface has to be managed by the Cygwin1 dll. On 32 bit the Unix and Windows C programming memory models are both ILP32 I believe, but Cygwin does not support the Pascal left to right argument calling convention and callee pop, and probably handles registers differently. The Cygwin host, build, target platform triplets are {x86_64,i686}-{pc-cygwin,w64-mingw32} - the OS is Cygwin or Mingw, neither Unix nor Windows. If a Cygwin build defines Windows macros, few GNU, BSD, or other Unix packages will build correctly, and no definitions expected by Windows programs or from MS compilers are available, so no Windows packages will build correctly. The Cygwin C library libc is newlib not glibc so not a lot of GNU nor all Posix interfaces are available. Mingw includes sufficient compatible Windows definitions to allow Windows interfaces to be built and run natively for interoperability. As far as I know, all gcc compilers target gas DEC/AT&T assembler pseudo-ops and instruction formats not MS or Intel pseudo-ops and/or instruction formats. The full Windows definitions are proprietary and are only available if a MS compiler is installed. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. -- 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