msvc: Fix compilation error due to missing mktemp() declaration
PATCH 1/1 msvc: Fix compilation error due to missing mktemp() declaration
Commit d1b6e6e (win32: use our own dirent.h, 2010-11-23) removed the compat/vcbuild/include/dirent.h compatibility header file. This file, among other things, included the <io.h> system header file which provides the declaration of the mktemp() function.
In order to fix the compilation error, we add an include directive for <io.h> to the compat/vcbuild/include/unistd.h header. (The MinGW build includes <io.h> from it's <unistd.h> header too.)
--- compat/vcbuild/include/unistd.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
compat/vcbuild/include/unistd.h +2 -0
@@ -1,6 +1,8 @@#ifndef _UNISTD_#define _UNISTD_ +#include <io.h> +/* Win32 define for porting git*/ #ifndef _MODE_T_
Signature · 1 line
1.7.3
Quoted 6 lines · Ramsay Jones
Commit d1b6e6e (win32: use our own
dirent.h, 2010-11-23) removed thecompat/vcbuild/include/dirent.hcompatibility header file. This file, among other things, included the <io.h> system header file which provides the declaration of themktemp()function.
Quoted 6 lines
In order to fix the compilation error, we add an include directive for <
io.h> to thecompat/vcbuild/include/unistd.hheader. (The MinGW build includes <io.h> from it's <unistd.h> header too.)Signed-off-by Ramsay Jones <[email protected]>---
Thanks. But shouldn't this header be included in mingw.h (or perhaps msvc.h) because of _get_osfhandle and _commit?
Quoted 11 lines · Erik Faye-Lund
Quoted 9 lines · Ramsay Jones
Commit d1b6e6e (win32: use our own
dirent.h, 2010-11-23) removed thecompat/vcbuild/include/dirent.hcompatibility header file. This file, among other things, included the <io.h> system header file which provides the declaration of themktemp()function.In order to fix the compilation error, we add an include directive for <
io.h> to thecompat/vcbuild/include/unistd.hheader. (The MinGW build includes <io.h> from it's <unistd.h> header too.)
Quoted 5 lines
Quoted 2 lines
Signed-off-by Ramsay Jones <[email protected]>---
Thanks. But shouldn't this header be included in
mingw.h(or perhapsmsvc.h) because of_get_osfhandleand_commit?
Er... no. ;-)
All uses of _get_osfhandle() and _commit() on the msvc build (after this patch) are within the scope of an appropriate declaration, so there is no *need* to include <io.h> in either mingw.h or msvc.h. [I'm confident the same is true of the MinGW build as well, but I didn't have time to check before sending this mail...]
I suspect that you already know this and I'm just being dumb in missing the import of your question... Perhaps you could clarify your concerns regarding this patch?
ATB,
Ramsay Jones
Quoted 26 lines · Ramsay Jones
Quoted 11 lines · Erik Faye-Lund
Quoted 9 lines · Ramsay Jones
Commit d1b6e6e (win32: use our own
dirent.h, 2010-11-23) removed thecompat/vcbuild/include/dirent.hcompatibility header file. This file, among other things, included the <io.h> system header file which provides the declaration of themktemp()function.In order to fix the compilation error, we add an include directive for <
io.h> to thecompat/vcbuild/include/unistd.hheader. (The MinGW build includes <io.h> from it's <unistd.h> header too.)Quoted 5 lines
Quoted 2 lines
Signed-off-by Ramsay Jones <[email protected]>---
Thanks. But shouldn't this header be included in
mingw.h(or perhapsmsvc.h) because of_get_osfhandleand_commit?Er... no. ;-)
All uses of
_get_osfhandle()and_commit()on the msvc build (after this patch) are within the scope of an appropriate declaration, so there is no *need* to include <io.h> in eithermingw.hormsvc.h. [I'm confident the same is true of the MinGW build as well, but I didn't have time to check before sending this mail...]
Quoted 4 lines
I suspect that you already know this and I'm just being dumb in missing the import of your question... Perhaps you could clarify your concerns regarding this patch?
Actually, I suspect that you know exactly what my concern is (based on the above), and that it's not with your patch.
I have a patch in my MSVC-tree that includes io.h in mingw.h, because mingw.h already depends on facilities from io.h on MSVC. My point was simply that this dependency was already present, and as such I think mingw.h is the appropriate place to include it.
Your patch might remove the warnings (perhaps it was only msvc.c that depends on io.h, I don't remember), and that's fine. But I think we should solve the problem in msvc.[ch] instread, as this is the compatibility-layer that the rest of the system includes.
But it's just an opinion, deal with it as you please. The most important part is to prevent warnings/errors, how we do it is secondary.
Quoted 2 lines · Erik Faye-Lund
Actually, I suspect that you know exactly what my concern is (based on the above), and that it's not with your patch.
Actually no, which is why I asked! :-D
Quoted 4 lines
I have a patch in my MSVC-tree that includes
io.hinmingw.h, becausemingw.halready depends on facilities fromio.hon MSVC. My point was simply that this dependency was already present, and as such I thinkmingw.his the appropriate place to include it.
OK, v2 of patch on the way...
ATB,
Ramsay Jones