This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [MinGW-w64]Build gdb/ctf.c failed
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Kai Tietz <ktietz70 at googlemail dot com>
- Cc: asmwarrior at gmail dot com, tromey at redhat dot com, yao at codesourcery dot com, gdb-patches at sourceware dot org
- Date: Mon, 25 Mar 2013 15:12:20 +0200
- Subject: Re: [MinGW-w64]Build gdb/ctf.c failed
- References: <83ip4s4ixc dot fsf at gnu dot org> <1363407692-18959-1-git-send-email-yao at codesourcery dot com> <1363407692-18959-4-git-send-email-yao at codesourcery dot com> <CADPb22RwSq0iv_gQu5PSGezQoUy0ve16M2hmL51HvM19v0M5Ow at mail dot gmail dot com> <51492077 dot 30307 at codesourcery dot com> <83sj3qyogk dot fsf at gnu dot org> <87vc8m7z1d dot fsf at fleche dot redhat dot com> <514FA117 dot 9030604 at gmail dot com> <83hajz3oef dot fsf at gnu dot org> <CAEwic4Y020-LqwtNeYFXn3oQvk5fWBFm1T5ZoAmwqPSpD=PASg at mail dot gmail dot com> <83boa73mty dot fsf at gnu dot org> <CAEwic4aP6EHo0Kxu=qxCF1MFNWPt02QoSAUyuRuN1riAJif8Yg at mail dot gmail dot com> <837gkv3maf dot fsf at gnu dot org> <CAEwic4ag2-dHuoZHwLApVdoYzb+ueP1+xV+sBa0NOnpB+s4NOg at mail dot gmail dot com> <8338vj3i1w dot fsf at gnu dot org> <CAEwic4Z0kRjmUuEh3y5h6uMCCSyzxwScGwzspD2jwxP1xYx3rA at mail dot gmail dot com>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> Date: Mon, 25 Mar 2013 13:42:52 +0100
> From: Kai Tietz <ktietz70@googlemail.com>
> Cc: asmwarrior@gmail.com, tromey@redhat.com, yao@codesourcery.com,
> gdb-patches@sourceware.org
>
> So, you claimed MinGW-w64 did something wrong ... well, if we wouldn't
> declare mkdir here, indeed it would be worth a bug-report ...
Actually, Posix says mkdir should be in sys/stat.h, not in unistd.h.
And it looks like MinGW64 does indeed have mkdir in stat.h, not in
unistd.h. Which IMO is another unfortunate incompatibility with
mingw.org.
> So what differences you were talking about?
The difference that caused the warning -- the fact that _mkdir's
prototype was not visible after including unistd.h.
> The function mkdir is declared for MinGW.org, and for MinGW-w64. It
> is the POSIX compliant API name and both ventures are declaring it
> in an POSIX-helper header.
Yes (but see below about its Posix nature).
> So you mean yet _mkdir?
Yes, of course. _mkdir was the reason for the compiler warning. If
it were declared in io.h, then the warning would not have been
emitted.
> if you want to use a posix function, include the corresponding posix
> header; if you want to a MS API, use the header MS defines the
> function/interface lives in. it wouldn't really help portability
> (in either direction) to support including a posix header, and
> getting a MS API function, so mingw doesn't lay its headers that
> way.
Unfortunately, this isn't so simple, as MS API offers mkdir as well
(see direct.h in any MS SDK), albeit while discouraging/deprecating
its use:
http://msdn.microsoft.com/en-us/library/vstudio/ms235326%28v=vs.100%29.aspx
Thus, mkdir is both a Posix API and an MS API. Moreover, the Posix
mkdir accepts 2 arguments, not one. So what MinGW provides is not
really a Posix API, but rather a slightly incompatible variant
thereof.
> The header io.h isn't a POSIX one, and therefore you should just
> expect what actual is documented by vendor (in msdn) for it and not
> what one implementation mightz does.
MinGW's unistd.h includes io.h, and thus gets both mkdir and _mkdir.
One could perhaps argue that this is or isn't a mistake, but given the
precedence, having a different arrangement in MinGW64 is unfortunate,
since it will mean more #ifdef'ing in the projects that want to
support both. For yet another example of such incompatibilities, see
http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00611.html