From: "Soegtrop, Michael" <michael.soegtrop@intel.com>
To: Agner Fog <agner@agner.org>, "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: RE: Why is __unix__ defined, and not __WINDOWS__ ?
Date: Mon, 13 May 2019 07:56:00 -0000 [thread overview]
Message-ID: <0F7D3B1B3C4B894D824F5B822E3E5A178FD6D132@IRSMSX102.ger.corp.intel.com> (raw)
In-Reply-To: <dfd043fb-620a-81a1-1611-91a982fc96cd@agner.org>
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
next prev parent reply other threads:[~2019-05-13 7:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-12 18:22 Agner Fog
2019-05-12 19:52 ` Houder
2019-05-12 19:54 ` Hans-Bernhard Bröker
2019-05-12 20:29 ` Lee
2019-05-13 4:12 ` Agner Fog
2019-05-13 5:40 ` Brian Inglis
2019-05-13 14:49 ` Agner Fog
2019-05-13 16:16 ` Yaakov Selkowitz
2019-05-13 7:56 ` Soegtrop, Michael [this message]
2019-05-12 20:33 ` Mike Gran via cygwin
2019-05-12 20:54 ` Houder
2019-05-13 4:40 ` Brian Inglis
2019-05-13 10:04 ` Houder
2019-05-12 22:00 ` Houder
2019-05-12 23:12 ` Houder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0F7D3B1B3C4B894D824F5B822E3E5A178FD6D132@IRSMSX102.ger.corp.intel.com \
--to=michael.soegtrop@intel.com \
--cc=agner@agner.org \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).