Change to stl::filesystem from Boost::filesystem

Everything about development and the OpenMW source code.
User avatar
Greendogo
Posts: 1467
Joined: 26 Aug 2011, 02:04

Change to stl::filesystem from Boost::filesystem

Post by Greendogo »

Hey, just wondering if there's any support for changing to stl::filesystem from Boost::filesystem now that it's supported in most compilers.

There are around 100 references to the Boost::filesystem library in the code right now which make up the VAST majority of Boost usage in the code base.
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: Change to stl::filesystem from Boost::filesystem

Post by AnyOldName3 »

We're still on C++11. There are good reasons why we'd want to switch to C++17 (getting std::filesystem is one of the big ones) but there are reasons not to, too.
User avatar
Greendogo
Posts: 1467
Joined: 26 Aug 2011, 02:04

Re: Change to stl::filesystem from Boost::filesystem

Post by Greendogo »

AnyOldName3 wrote: 14 Oct 2019, 22:51 ... but there are reasons not to, too.
What are all of the reasons?
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: Change to stl::filesystem from Boost::filesystem

Post by AnyOldName3 »

There are still OSes out there that are fairly major, are still supported, and don't properly support new C++ versions. Back when we were discussing upgrading to C++14 a couple of years ago, it was pointed out that Ubuntu 14.04 LTS was still in its support period, but you had to install GCC from a testing PPA to get C++14 support. It's going to be a similar story for C++17 for a while yet.

Also, even if all the major compilers nominally support the full standard, it's not guaranteed that their support is bug-free. It's safer to leave a release for a while for other projects to encounter and report any issues rather than find that OpenMW suddenly stops working on Windows because a Linux dev used a C++17 feature that's crashy with VC but fine in GCC or vice versa.

These are the two main reasons. There are also minor ones, like devs being lazy and having old IDE versions. I only got around to switching from VS 2015 to 2017 in the summer, and now 2019's out. VS 2019 is the first version to officially support std::filesystem (2017 had std::experimental::filesystem, which had a few differences which were gradually corrected over its lifetime) so everyone would have to be very up to date.
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Change to stl::filesystem from Boost::filesystem

Post by psi29a »

I've have a 3 year old branch that does this... what is holding us up? MacOS... XCode... they are just not there yet.
https://github.com/OpenMW/openmw/pull/1526

MSVC and GCC are there... LLVM as well, but not the version that Mac uses.
AnyOldName3 wrote: 14 Oct 2019, 22:51 We're still on C++11. There are good reasons why we'd want to switch to C++17 (getting std::filesystem is one of the big ones) but there are reasons not to, too.
You sure? I thought I pushed us to C++14 not so long ago?
https://github.com/OpenMW/openmw/pull/2314
AnyOldName3 wrote: 15 Oct 2019, 00:33 There are still OSes out there that are fairly major, are still supported, and don't properly support new C++ versions. Back when we were discussing upgrading to C++14 a couple of years ago, it was pointed out that Ubuntu 14.04 LTS was still in its support period, but you had to install GCC from a testing PPA to get C++14 support. It's going to be a similar story for C++17 for a while yet.
Yes, I fixed this and helped Zini as well to make the switch to use the PPA.

So yeah, in theory we could just drop xcode and use gcc to work around MacOS/XCode... or we can wait a bit for them to catch up.
Chris
Posts: 1625
Joined: 04 Sep 2011, 08:33

Re: Change to stl::filesystem from Boost::filesystem

Post by Chris »

How similar are the Boost and STL filesystem APIs? Would it be possible to selectively alias one so it uses STL on supported systems and Boost as a fallback? e.g.

Code: Select all

namespace omw {
#if __cplusplus >= 201703L
using filesystem = std::filesystem;
#else
using filesystem = Boost::filesystem;
#endif
} // namespace omw
Then use omw::filesystem throughout the codebase.
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: Change to stl::filesystem from Boost::filesystem

Post by AnyOldName3 »

They're not identical.
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: Change to stl::filesystem from Boost::filesystem

Post by AnyOldName3 »

Also, I saw the original C++14 PR had been closed, and that was what showed up on Google, and wasn't aware there was a second one. It's good to know that we're relatively up to date.

I'm still wanting OSG to switch to C++11 so I can get rid of a footgun that causes undefined behaviour in a way that has no performance hit, as Robert rejected the pre-11 PR I made.
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Change to stl::filesystem from Boost::filesystem

Post by psi29a »

Is there already a PR for OSG to switch it up to C++11 ?
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: Change to stl::filesystem from Boost::filesystem

Post by AnyOldName3 »

It was going to be 'the thing' that tipped OSG from 3.x to 4.x, but that was before VSG was announced, so it may never happen. VSG is C++ 17, though, so potentially that'll make Robert passionately anti-pre-11 C++.
Post Reply