ami-iit / meshcat-cpp

Self-contained C++ interface for the MeshCat visualizer
BSD 3-Clause "New" or "Revised" License
25 stars 4 forks source link

C++20 #7

Closed jcarpent closed 1 year ago

jcarpent commented 1 year ago

Dear developers,

Thanks a lot for extracting from Drake this very useful Meshcat interface.

I've a simple but important question regarding the choice of C++20. Is it fully needed to run meshcat-cpp?

Thanks in advance, Best,

Justin

traversaro commented 1 year ago

Hello @jcarpent ! Despite what is written in the README, what we actually need is some basic C++20 features, not full support for C++20 (see https://github.com/ami-iit/meshcat-cpp/pull/6 and https://github.com/ami-iit/meshcat-cpp/pull/3#issuecomment-1480837312).

Just to understand, which compilers/distro you would like to use meshcat-cpp in?

jcarpent commented 1 year ago

In general, I'm trying to lower the need for advanced C++ features, if not mandatory. For instance, for Ubuntu 20.04, the default C++ version is 9.3.0 which does not provide all the C++20 features.

traversaro commented 1 year ago

The library works fine with the default C++ compiler in Ubuntu 20.04, see the apt CI in https://github.com/ami-iit/meshcat-cpp/blob/38d97bd0828b0a901818f58be090f7ec60c02e5f/.github/workflows/apt-ci.yaml, even if the C++20 mode is not set in the compiler (this was the case before https://github.com/ami-iit/meshcat-cpp/pull/3). We switched to required C++20 in the CMake as otherwise the library would not compile in Windows, as there is a minor C++ feature used in the library (designated initializer) is technically part of C++20, and otherwise the library was not compiling on Windows (see https://github.com/ami-iit/meshcat-cpp/pull/3#issuecomment-1480837312).

If the cxx_std_20 requirement is problematic for any specific use case we can always just set it only for Windows, but it would be great if any such requirement could be added in the CI, otherwise it would be quite probable that we could have regression w.r.t. to that.

jcarpent commented 1 year ago

I would suggest just forcing C++20 for Windows if it is only a fix. Thanks a lot @traversaro and colleagues for your great efforts on open-source software. It is very precious and helpful.

Best, Justin