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.
Change to stl::filesystem from Boost::filesystem
- AnyOldName3
- Posts: 2677
- Joined: 26 Nov 2015, 03:25
Re: Change to stl::filesystem from Boost::filesystem
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.
Re: Change to stl::filesystem from Boost::filesystem
What are all of the reasons?
- AnyOldName3
- Posts: 2677
- Joined: 26 Nov 2015, 03:25
Re: Change to stl::filesystem from Boost::filesystem
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.
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.
- psi29a
- Posts: 5361
- Joined: 29 Sep 2011, 10:13
- Location: Belgium
- Gitlab profile: https://gitlab.com/psi29a/
- Contact:
Re: Change to stl::filesystem from Boost::filesystem
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.
https://github.com/OpenMW/openmw/pull/2314
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.
https://github.com/OpenMW/openmw/pull/1526
MSVC and GCC are there... LLVM as well, but not the version that Mac uses.
You sure? I thought I pushed us to C++14 not so long ago?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.
https://github.com/OpenMW/openmw/pull/2314
Yes, I fixed this and helped Zini as well to make the switch to use the PPA.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.
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.
Re: Change to stl::filesystem from Boost::filesystem
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.
Then use omw::filesystem throughout the codebase.
Code: Select all
namespace omw {
#if __cplusplus >= 201703L
using filesystem = std::filesystem;
#else
using filesystem = Boost::filesystem;
#endif
} // namespace omw
- AnyOldName3
- Posts: 2677
- Joined: 26 Nov 2015, 03:25
Re: Change to stl::filesystem from Boost::filesystem
They're not identical.
- AnyOldName3
- Posts: 2677
- Joined: 26 Nov 2015, 03:25
Re: Change to stl::filesystem from Boost::filesystem
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.
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.
- psi29a
- Posts: 5361
- Joined: 29 Sep 2011, 10:13
- Location: Belgium
- Gitlab profile: https://gitlab.com/psi29a/
- Contact:
Re: Change to stl::filesystem from Boost::filesystem
Is there already a PR for OSG to switch it up to C++11 ?
- AnyOldName3
- Posts: 2677
- Joined: 26 Nov 2015, 03:25
Re: Change to stl::filesystem from Boost::filesystem
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++.