Compile PCL as C++17 by default, switching back to C++14 currently still possible #6201
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mainly due to https://eigen.tuxfamily.org/dox/group__TopicStructHavingEigenMembers.html Before C++17, certain PCL classes/structs have to be annotated with
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
. Since C++17, that macro is empty, which creates possible incompatibilities between PCL and the user project. #5793 implemented a workaround, which meant that the old mechanism ofEIGEN_MAKE_ALIGNED_OPERATOR_NEW
was still used in newer C++ standards. Since many compilers support C++17 now, making it the new default in PCL seems logical. According to Wikipedia, these compilers have full support for C++17: https://en.wikipedia.org/wiki/C%2B%2B17#Compiler_supportAdditionally, GCC 7, Clang 4, and MSVC >= 19.12 might work since they support the relevant C++17 feature "Dynamic memory allocation for over-aligned data".
Related issue: #6126
With this change, PCL will be compiled as C++17 by default (previously: C++14 by default). Compiling as C++14 is currently still possible via
-DCMAKE_CXX_STANDARD=14 -DCMAKE_CUDA_STANDARD=14
.If PCL is compiled as C++17 or newer, projects using PCL have to be compiled as C++17 or newer (this was previously not enforced). When using CMake, this is done automatically.
If PCL is compiled as C++14, projects using PCL have to be compiled as C++14 or newer. However,
EIGEN_HAS_CXX17_OVERALIGN=0
has to be defined in the user project (when using CMake, this is done automatically).Note: MSC_VER 1912 is chosen because since that version, the C++17 feature "Dynamic memory allocation for over-aligned data" is available in MSVC. Eigen uses the same version number to determine
EIGEN_HAS_CXX17_OVERALIGN
.The CUDA compiler on Ubuntu 20.04 (CUDA toolkit 10.1) does not work with C++17/CUDA17.
The clang-tidy warnings regarding modernize-use-auto only appeared after setting the compile default to C++17, for some reason.