Sv: g++ and c++17 filesystem
Thu Nov 19 10:03:23 GMT 2020

> > 18 nov. 2020 kl. 17:26 skrev René Berber via Cygwin <>:
> >
> > On 11/18/2020 3:00 AM, Kristian Ivarsson via Cygwin wrote:
> >
> >>>> On 11/17/2020 9:15 AM, Kristian Ivarsson via Cygwin wrote:
> >>>
> >>>> The filesystem-library as a part of C++17 seems to have some
> >>>> defects and flaws in the cygwin-package and pretty much every
> >>>> lexical- and canonical operation works in mysterious ways (or not
> >>>> at all)
> >>> [snip]
> >>>
> >>>

> As stated earlier, it seems like using mingw g++/libstdc++ (from the
> cygwin-package-manager) it seems like it works better, but then you can’t
> mix with other posix/cygwin mechanism (that uses cygstdc++) without
> breaking ODR (and probably some memory models etc as well) so maybe
> someone do have some insightful info about this ? How “special” is
> cygstdc++ (compared to mingw:s libstdc++) ? Could this be fixable in that
> library (cygstdc++) ?

I think the problem can be viewed in /usr/lib/gcc/x86_64-pc-cygwin/10/include/c++/bits/fs_path.h and

 #if defined(_WIN32) && !defined(__CYGWIN__)
 # include <algorithm>

that when build in CYGWIN will make the stdc++ think it is not on Windows (and I guess cygstdc++-6.dll will be built without _GLIBCXX_FILESYSTEM_IS_WINDOWS implicitly), thus, the std::filesystem-library will act as it is on a Posix-system, but it is not and thus it makes wrong assumptions

It seems like the (ordinary) MinGW-shipping includes these directives (!defined(__CYGWIN__)) as well and my naive take on this is that it is a (the) mistake

The underlaying filesystem IS Windows and NOT Posix, but my guess is that (some) Posix-system-calls and/or assuming Posix-style-paths are invoked when _GLIBCXX_FILESYSTEM_IS_WINDOWS is not set

I guess the correct way would be to let _GLIBCXX_FILESYSTEM_IS_WINDOWS and maybe just have a #ifdef (__CYGWIN__) as an extra option ONLY when handling lexical stuff, i.e. it allows both Windows- and Posix-styles but the system calls should always be Windows calls (and I guess this would imply better performance as well to not need to walk through the whole Cygwin-posix-abstraction)

I might be totally wrong, so does anyone have any take on this ?

Best regards,

> Best regards,
> Kristian

More information about the Cygwin mailing list