Usage of C++20/23

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
xtemp09
Posts: 72
Joined: Tue Jul 12, 2022 2:16 pm

Usage of C++20/23

Post by xtemp09 »

What do venerable developers think about usage C++20/23?
  1. usage of std::format instead of boost::format
    std::regex instead of boost::regex
    std::bind instead of boost::bind (though, I use lambda functions, because I found them to be much faster)
    std::isnan instead of boost::math::isnan
    std::filesystem instead of boost::filesystem
    usage of [[maybe_unused]] or Q_UNUSED, since, it's Qt (also, [[likely]], [[unlikely]] etc.)
    and many more, like std::span
  2. creation of portable version of FreeCAD. I know that there is "portable" version, but it's only called like that.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Usage of C++20/23

Post by onekk »

already discussed.

There are work to modernize codebase, however main problem seems to be the different ways compilers implement new features that is sparse across different OS as FreeCAD should compile 'at least' on Windows, MacOS and Linux and each of them has a different C++ compiler.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
xtemp09
Posts: 72
Joined: Tue Jul 12, 2022 2:16 pm

Re: Usage of C++20/23

Post by xtemp09 »

I could not find discussion on this topic. Could you provide me a link?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Usage of C++20/23

Post by wmayer »

What do venerable developers think about usage C++20/23?
The move to C++20 is not yet possible because we still have to support older systems that don't have full-featured C++20 compilers. For more information see also viewtopic.php?t=72173
usage of std::format instead of boost::format
Using std::format and friends was also on my wish list but that's one of the C++20 features that is not supported on older systems. So the alternative is to use the fmtlib that provides the needed functionality.
std::regex instead of boost::regex
Nope. This is one of the things we must not change because it's known that std::regex is up to 60x slower than boost::regex.
https://github.com/FreeCAD/FreeCAD/pull/1713
std::bind instead of boost::bind (though, I use lambda functions, because I found them to be much faster)
Yes, replacing boost::bind is fine.
std::isnan instead of boost::math::isnan
I didn't even know that this exists. Since it has been added with C++11 it's fine to change it.
std::filesystem instead of boost::filesystem
This library has actually been added with C++17 but we postponed the change because it was not fully supported on older systems with a C++17 compiler. So, this should be discussed again.
usage of [[maybe_unused]] or Q_UNUSED, since, it's Qt (also, [[likely]], [[unlikely]] etc.)
We partially use this already. Further options are std::ignore (but there are different opinions whether it should be used in this context) or boost::ignore_unused
and many more, like std::span
Is also a C++20 feature.
creation of portable version of FreeCAD. I know that there is "portable" version, but it's only called like that.
What would be the difference from a technical point of view?
xtemp09
Posts: 72
Joined: Tue Jul 12, 2022 2:16 pm

Re: Usage of C++20/23

Post by xtemp09 »

Thanks for this comprehensive reply, there is much to think of.

The link you provided says that the language is C++17 with some C++20 features. std::span, three-way comparison operator, attributes [[likely]], [[unlikely]], [[maybe_unused]] and [[nodiscard]] are supported by GCC 10 supplied with Ubuntu 18.04, which support ends in 2023-04. mingw-w64 v10 (GCC 13) still supports Windows 7, which is minimal Windows version.

A portable version of FreeCAD is always good for usage on another computer and, of course, α- and β-testing.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Usage of C++20/23

Post by wmayer »

supplied with Ubuntu 18.04, which support ends in 2023-04
Ubuntu 18.04 is no longer the reference. We have decided for Ubuntu 20.04 as the minimum version.

Xubuntu 18.04 was my previous system and due to moves to newer versions of some libs (e.g. Python, Qt) or tools (e.g. cmake) I have moved to Xubuntu 22.04.
A portable version of FreeCAD is always good for usage on another computer and, of course, α- and β-testing.
Of course but my question was more about how to create such a portable version compared to what we have now.
xtemp09
Posts: 72
Joined: Tue Jul 12, 2022 2:16 pm

Re: Usage of C++20/23

Post by xtemp09 »

Every compilation log is filled with warnings about deprecation of iterators and set-but-not-used variables in SALOME's MESH code, taking 2500 lines of output. -Wdeprecated-declarations and -Wunused-but-set-variable will eliminate all of them. Perhaps, addition of [[maybe_unused]] is a sound approach, nevertheless, rewriting of iterators is a totally different thing.

The question how to create a portable version of FreeCAD is beyond my area of expertise, though, I hope, there are still developers who know.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Usage of C++20/23

Post by adrianinsaval »

xtemp09 wrote: Fri Feb 03, 2023 12:24 pm mingw-w64 v10 (GCC 13) still supports Windows 7, which is minimal Windows version.
IIRC we don't have full mingw support, msvc is the baseline for these decisions, don't know what version.
xtemp09 wrote: Sat Feb 04, 2023 6:16 am The question how to create a portable version of FreeCAD is beyond my area of expertise, though, I hope, there are still developers who know.
the portability thing then has nothing to do with c++ 20? I recommend not mixing topics in the same forum thread, it can get confusing and hard to follow.
User avatar
chennes
Veteran
Posts: 3879
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Usage of C++20/23

Post by chennes »

adrianinsaval wrote: Sat Feb 04, 2023 8:27 pm IIRC we don't have full mingw support
This should not be true, @wmayer and I did some work in this area last year and last time I checked it worked well. Maybe something has changed in the interim?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
xtemp09
Posts: 72
Joined: Tue Jul 12, 2022 2:16 pm

Re: Usage of C++20/23

Post by xtemp09 »

adrianinsaval wrote: Sat Feb 04, 2023 8:27 pmthe portability thing then has nothing to do with c++ 20? I recommend not mixing topics in the same forum thread, it can get confusing and hard to follow.
I considered creation of two topics on two small questions was not right. Feel free to create another topic where we will move our discussion.

I still stand for what I wrote. Every output log is completely filled with warnings about deprecated features and unused variables. Their removal will clear the compilation log, facilitating analysis.

I saw these two messages (one, posted by you, and two) on "portable" version. I still think actual portable version of FreeCAD is a good idea.
Post Reply