[MinGW-w64]Build gdb/ctf.c failed

asmwarrior
2013-03-25T00:53:38Z

On 2013-3-21 1:37, Tom Tromey wrote:
>>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>
>>> Date: Wed, 20 Mar 2013 10:35:35 +0800
>>> From: Yao Qi <yao@codesourcery.com>
>>> CC: gdb-patches <gdb-patches@sourceware.org>, Eli Zaretskii <eliz@gnu.org>
>>>
>>> Also define a macro 'mkdir' in this patch, as Eli suggested before. Is
>>> it OK?
>
> Eli> The macro is OK, but please make sure unistd.h is included by this
> Eli> file, because that's where MinGW defines the prototype of _mkdir.
>
> defs.h includes unistd.h.
>
> Tom
>
Hi, all. I'm using the GCC suite with MinGW-w64 SDKs. There is a little different from the MinGW SDKs.
I get the build error:

mingw32-gcc -O0 -g -D__USE_MINGW_ACCESS -I. -I../../gdb/gdb -I../../gdb/gdb/common -I../../gdb/gdb/config -DLOCALEDIR="\"/mingw/share/locale\"" -DHAVE_CONFIG_H -I../../gdb/gdb/../include/opcode -I../../gdb/gdb/../opcodes/.. -I../../gdb/gdb/../readline/.. -I../bfd -I../../gdb/gdb/../bfd -I../../gdb/gdb/../include -I../libdecnumber -I../../gdb/gdb/../libdecnumber -I../../gdb/gdb/gnulib/import -Ibuild-gnulib/import -IE:/code/python273/include -IE:/code/python273/include -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wno-format -Werror -c -o ctf.o -MT ctf.o -MMD -MP -MF .deps/ctf.Tpo ../../gdb/gdb/ctf.c
../../gdb/gdb/ctf.c: In function 'ctf_start':
../../gdb/gdb/ctf.c:304:3: error: implicit declaration of function '_mkdir' [-Werror=implicit-function-declaration]
cc1.exe: all warnings being treated as errors
make[2]: *** [ctf.o] Error 1

I found that _mkdir was declared in the file: direct.h in MinGW-w64 SDKs:
_CRTIMP int __cdecl _mkdir(const char *_Path);

And it looks like no other header files include direct.h, so #include <direct.h> is needed here.

For MinGW SDKs, as Tom said, it was indirectly included in defs.h, this there is no such issue.

Yuanhui Zhang

BTW:
Do we need to add a check like below(We don't have such check in GDB, but I found such a check in other place):
/* Define to 1 if you have the <direct.h> header file. */
#define HAVE_DIRECT_H 1