lzip-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: mingw patch for mkdir()


From: wrotycz
Subject: Re: Re: mingw patch for mkdir()
Date: Mon, 05 Feb 2024 20:29:51 +0100
User-agent: GWP-Draft


I have fixed it mostly as you suggest, but prepending an underscore as
suggested by gnulib[1].

Hello,  just searched mkdir in mingw/include:

```
mingw/include $ grep -r -nH mkdir *
direct.h:34:  _CRTIMP int __cdecl _mkdir(const char *_Path);
direct.h:55:  _CRTIMP int __cdecl _wmkdir(const wchar_t *_Path);
direct.h:65:  int __cdecl mkdir(const char *_Path) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
io.h:282:  int __cdecl mkdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
tchar.h:326:#define _tmkdir _wmkdir
tchar.h:650:#define _tmkdir _mkdir
wchar.h:299:  _CRTIMP int __cdecl _wmkdir(const wchar_t *_Path);
```
It's the same for mingw-gcc v5, v8, v12.

Thread: [Mingw-w64-public] mkdir and MINGW_ATTRIB_DEPRECATED_MSVC2005
sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/CAHnU2db1pn6f6ZETLmihaYqAzJ_8QjPrGRxjRqWXBGesNAcbdA%40mail.gmail.com/#msg35714669

Win32 mkdir vs _mkdir
stackoverflow.com/questions/33326732/win32-mkdir-vs-mkdir

"Only the old name is deprecated, not the function, and only in Visual Studio, not in POSIX.
Basically, the reason is that mkdir isn't defined as a runtime library function in the ISO C++ standard, and non-standard runtime library functions are expected to begin with an underscore."

And it, indeed is not covered by C standard



_mkdir is microsoft thing:
learn.microsoft.com/en-us/cpp/c-runtime-library/reference/mkdir

"The Microsoft-implemented POSIX function name mkdir is a deprecated alias for the _mkdir function. By default, it generates Compiler warning (level 3) C4996. The name is deprecated because it doesn't follow the Standard C rules for implementation-specific names. However, the function is still supported.
We recommend you use _mkdir instead. Or, you can continue to use this function name, and disable the warning. For more information, see Turn off the warning and POSIX function names."

I don't know the stand of mingw of other compiler developers, what is and what is not standard/non standard, deprecated or not, but I, personally, would use mkdir, just because it does not compile on MSVC. I mean, last time I tested it compiled but did not work - it produced corrupetd bitstream somewhere on the way.
But that's my opinion. If Gnulib says to use underscore I get that. You'll have to add `#include <direct.h>' along with `<io.h>' otherwise you get: `implicit declaration of function '_mkdir''.

```
main.c: In function 'make_dirs':
main.c:45:26: warning: implicit declaration of function '_mkdir'; did you mean 'mkdir'? [-Wimplicit-function-declaration]
#define mkdir(name,mode) _mkdir(name)
                          ^~~~~~
```
en.wikipedia.org/wiki/Direct.h


You should definitely get your own mingw copy to test that as well. I use it through wine, with msys. I have old msys-1, which is bash with posix tools, and as it does not introduce its own dependencies.
(mediafire.com/file/xwn8jh9l908u7rn/msys-1.10.zip/file)
Fill $MSYS_DIR/etc/fstab as in example/s and:

```
$ cd $MSYS_DIR
$ wine cmd.exe
z:\msys> msys_mintty.bat
# or msys_sh.bat
z:\msys> gcc -v
```


reply via email to

[Prev in Thread] Current Thread [Next in Thread]