Why is _WIN64 not defined as 1 in _cygwin.h?

Z. Majeed zmajeed@sbcglobal.net
Wed Nov 24 14:17:06 GMT 2021


I've run into this problem while porting Intel oneTBB to cygwin - there are some places where I need to use Win32 versions of code in oneTBB for cygwin because the Linux version is not supported in cygwin - one example is the missing VmPeak stat in /proc/self/status
This means the cygwin port sometimes needs to conditionally include windows.h
This leads to the Windows 64-bit feature test macro _WIN64 getting defined with no value in /usr/include/w32api/_cygwin.h - full discussion here https://cygwin.com/pipermail/cygwin-developers/2012-July/010732.html
/* _WIN64 is defined by the compiler specs when targeting Windows.   The Cygwin-targeting gcc does not define it by default, same as   with _WIN32.  Therefore we set it here.  The result is that _WIN64   is only defined if Windows headers are included. */#ifdef __x86_64__#define _WIN64#endif
This gives compile errors wherever _WIN64 is used in oneTBB code in expressions like
#if _WIN32 || _WIN64
e.g. at https://github.com/oneapi-src/oneTBB/blob/master/test/tbbmalloc/test_malloc_compliance.cpp#L38
The _WIN64 predefined macro is documented at https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
"_WIN64 Defined as 1 when the compilation target is 64-bit ARM or x64. Otherwise, undefined."
Why has cygwin chosen to define _WIN64 with no value?
Can _WIN64 instead be defined as 1 per Microsoft specification?
My port of oneTBB to cygwin is described at https://github.com/oneapi-src/oneTBB/issues/156
Thanks,Zartaj



More information about the Cygwin-developers mailing list