Web lists-archives.com

Re: Why is __unix__ defined, and not __WINDOWS__ ?




On Sun, 12 May 2019 20:22:36, Agner Fog  wrote:
> 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?
> 
> 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.

Hans-Bernhard Bröker is correct ...

But if you were thinking of a "mixed" executable (be careful), then
the _WIN* mnemonics will be defined by gcc/g++.

(see the /include/w32api/{_mingw,_cygwin}.h headers)

Henri

64-@@ printf '#include <windows.h>' | gcc -dM -E - | grep -i win64
#define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
#define _WIN64
#define __RPC_WIN64__
64-@@ printf '#include <windows.h>' | g++ -dM -E -x c++ - | grep -i win64
#define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
#define _WIN64
#define __RPC_WIN64__

=====


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