This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH GOLD] [6/N mingw host] Add support for not keeping the files open on execute
JonY wrote:
> So "#if defined(_WIN32) && !defined(__CYGWIN__)" would effectively be
> equivalent to checking for __MSVCRT__ right?
No. (Well, "maybe" -- but only by luck)
I generally interpret "_WIN32" to mean "the functions defined in the MS
Windows API are available" -- which says exactly nothing about the C
runtime library being used. Since the windows api is only available on
the Window operating system (or clones, like wine), this symbol can be
used as a proxy for that:
if _WIN32 then MS-OpSys.
also, if MS-OpSys then _WIN32
__MSVCRT__ means "The Microsoft C Runtime is being used". This is true
for the Visual Studio compiler and the mingw32/mingw64 compiler. It may
also be true for some other compilers, like Borland or Intel, but I'm
not sure about that. Naturally, since the MS C runtime is only available
on the Windows Operating system, this symbol can be used as a proxy for
that:
if __MSVCRT__ then MS-OpSys.
but the following is NOT true:
if MS-OpSys then __MSVCRT__
because there ARE other C runtimes in use on the Windows platform;
cygwin is one. I think interix is another (although I'm not sure if
interix programs, acting inside the "Posix Subsystem" have access to
either the MS C runtime OR to the win32 api, but that's not germane to
this discussion).
I think you need to be clear about what your #ifdefs are checking.
__MSVCRT__ should be used to guard behavior differences between the MS C
runtime, and other runtimes on the windows platform (cygwin, interix,
etc) or other platforms entirely. Stuff like "the %E printf spec
results in an exponent with three digits, not two, in the MS C runtime".
I believe it is more appropriate, in the cases we're discussing here, to
guard around "The Win32 API is available" (e.g. _WIN32). However, since
on cygwin -- in most cases -- you don't want to USE the win32 api even
if it is available -- the formulation I posted originally is the correct
one:
#if defined(_WIN32) && !defined(__CYGWIN__)
To be REALLY clever, you'd define your own symbols like USE_WIN32_API
and HAVE_WIN32_API -- where the former is effectively
defined(_WIN32) && !defined(__CYGWIN__)
and the latter is effectively
defined(_WIN32) || defined(__CYGWIN__).
or some other, more complicated algorithm using configure hackery.
But nobody bothers with that...
> I'm not sure if checking for __MSVCRT__ is entirely correct, are there
> other runtimes on Windows to take into consideration?
Yes, there are (in general). I'm not sure if they currently matter with
regards to GOLD, tho.
--
Chuck