Why is __unix__ defined, and not __WINDOWS__ ?

Yaakov Selkowitz yselkowitz@cygwin.com
Mon May 13 16:16:00 GMT 2019


On Mon, 2019-05-13 at 16:49 +0200, Agner Fog wrote:
> On 13/05/2019 07.39, Brian Inglis wrote:
> > 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.
> 
> I tried this:
> 
> > int test (int x) {
> >     return x + 1;
> > }
> g++ -S -O2 t.cpp
> 
> Assembly output from g++ or clang:
> 
> > _Z4testi:
> > .LFB0:
> >         .seh_endprologue
> >         leal    1(%rcx), %eax
> >         ret
> >         .seh_endproc
> 
> The Win64 ABI has the paramter in ecx or rcx, the SysV ABI has it in edi.
> 
> A dump of the object file shows it is in COFF64 format.
> 
> The object file obeys the Win64 ABI and links directly into a Win64 
> project. The cygwin dll is not needed if the rest of the executable is 
> made with another compiler.
> 
> The executable runs under Windows, not under Linux.

The point of Cygwin is that the underlying Windows kernel and APIs are
abstracted, so that code meant for *NIX platforms just compiles and
runs as if it would elsewhere.

The current behaviour is correct and is not going to be changed.  If
you want to use Windows APIs, you can use our MinGW-w64 toolchains to
cross-compile.

--
Yaakov



--
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



More information about the Cygwin mailing list