Change to stl::filesystem from Boost::filesystem

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

Change to stl::filesystem from Boost::filesystem

Post by Greendogo » 14 Oct 2019, 22:34

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: 1665
Joined: 26 Nov 2015, 03:25

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

Post by AnyOldName3 » 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.
AnyOldName3, Master of Shadows

User avatar
Greendogo
Posts: 1418
Joined: 26 Aug 2011, 02:04

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

Post by Greendogo » 15 Oct 2019, 00:05

AnyOldName3 wrote:
14 Oct 2019, 22:51
... but there are reasons not to, too.
What are all of the reasons?

User avatar
AnyOldName3
Posts: 1665
Joined: 26 Nov 2015, 03:25

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

Post by AnyOldName3 » 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.

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.
AnyOldName3, Master of Shadows

User avatar
psi29a
Posts: 4699
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 » 15 Oct 2019, 13:44

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: 1565
Joined: 04 Sep 2011, 08:33

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

Post by Chris » 15 Oct 2019, 13:51

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: 1665
Joined: 26 Nov 2015, 03:25

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

Post by AnyOldName3 » 15 Oct 2019, 14:10

They're not identical.
AnyOldName3, Master of Shadows

User avatar
AnyOldName3
Posts: 1665
Joined: 26 Nov 2015, 03:25

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

Post by AnyOldName3 » 15 Oct 2019, 14:12

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.
AnyOldName3, Master of Shadows

User avatar
psi29a
Posts: 4699
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 » 17 Oct 2019, 08:46

Is there already a PR for OSG to switch it up to C++11 ?

User avatar
AnyOldName3
Posts: 1665
Joined: 26 Nov 2015, 03:25

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

Post by AnyOldName3 » 17 Oct 2019, 12:16

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++.
AnyOldName3, Master of Shadows

Post Reply