Most of the C++ examples fail to compile independently. OpenSim is using std::conditional_tin Array.h. This is a feature that was introduced in c++14 which is shown here in the helper types section. The cmake files for most of the examples are set to c++11 and therefore do not compile independently and produce the following error:
~/opensim-core/sdk/include/OpenSim/Common/Array.h:583:26: error: ‘conditional_t’ in namespace ‘std’ does not name a template type; did you mean ‘conditional’?
583 | using storage = std::conditional_t<
| ^~~~~~~~~~~~~
| conditional
~/opensim-core/sdk/include/OpenSim/Common/Array.h:589:5: error: ‘storage’ does not name a type
589 | storage _storage;
| ^~~~~~~
~/opensim-core/sdk/include/OpenSim/Common/Array.h: In constructor ‘OpenSim::Array<T>::Array(T, int, int)’:
~/opensim-core/sdk/include/OpenSim/Common/Array.h:66:9: error: ‘_storage’ was not declared in this scope
66 | _storage.reserve(aCapacity);
| ^~~~~~~~
Note: The examples compile within the OpenSim build because there is an override to c++14 in one of the top level CMakeLists.txt files for OpenSim.
Solution
Change the line for set(CMAKE_CXX_STANDARD 11) to at least set(CMAKE_CXX_STANDARD 14) in each examples CMakeLists.txt
I can submit a pull request that updates all of the examples CMakeLists.txt files to c++14 if it would be helpful.
Problem
Most of the C++ examples fail to compile independently. OpenSim is using
std::conditional_t
in Array.h. This is a feature that was introduced inc++14
which is shown here in the helper types section. The cmake files for most of the examples are set toc++11
and therefore do not compile independently and produce the following error:Solution
Change the line for
set(CMAKE_CXX_STANDARD 11)
to at leastset(CMAKE_CXX_STANDARD 14)
in each examplesCMakeLists.txt
I can submit a pull request that updates all of the examples
CMakeLists.txt
files toc++14
if it would be helpful.