Skip to content

[compile error] MSVC 2015 does not fully support constexpr declarations #4248

@nicolas-cadart

Description

@nicolas-cadart

Describe the error

It seems impossible to compile PCL with version >= 1.10.0 on Windows with MSVC 2015.

Apparently, Microsoft Visual Studio 2015 Update 3 does not have full support of constexpr expressions. This full support comes with MSVC 2017.

From PCL 1.10.0, some constexpr have been introduced in some basic files such as pcl/common/include/pcl/point_types.h or pcl/common/src/parse.cpp. However, these expressions are apparently not resolved at compile-time, and therefore does not exist when the compiler reaches their uses later on. This prevents compilation.

PCL 1.10.0 drops MSVC 2013 support, but not MSVC 2015. Therefore either its support should be deprecated, or fixed.

To Reproduce

After having set the dependencies from cmake-gui, I get the following errors :

C:\software\pcl\build>ninja -j1
[5/269] Building CXX object io\CMakeFiles\pcl_io.dir\src\ascii_io.cpp.obj
FAILED: io/CMakeFiles/pcl_io.dir/src/ascii_io.cpp.obj
C:\PROGRA~2\MICROS~1.0\VC\bin\X86_AM~1\cl.exe  /nologo /TP -DBOOST_LIB_DIAGNOSTIC -DPCLAPI_EXPORTS -Iinclude -IC:\software\pcl\src\common\include -IC:\software\pcl\src\octree\include -IC:\software\pcl\src\openni\include -IC:\software\pcl\src\openni2\include -IC:\software\pcl\src\ensenso\include -IC:\software\pcl\src\davidSDK\include -IC:\software\pcl\src\dssdk\include -IC:\software\pcl\src\rssdk\include -IC:\software\pcl\src\rssdk2\include -IC:\software\pcl\src\pcap\include -IC:\software\pcl\src\png\include -IC:\software\pcl\src\vtk\include -IC:\software\pcl\src\io\include -IC:\VV\build\install\include\eigen3 -IC:\software\pcl\src\recognition\include\pcl\recognition\3rdparty -IC:\VV\build\install\include\boost-1_66 /DWIN32 /D_WINDOWS /W3 /GR /EHsc /fp:precise /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355  /FS -openmp -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB /MD /O2 /Ob2 /DNDEBUG /GL   -DBOOST_ALL_NO_LIB -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -DPCL_ONLY_CORE_POINT_TYPES  -D__SSSE3__ -D__SSE2__ -D__SSE__ /bigobj /MP12 -std:c++14 /showIncludes /Foio\CMakeFiles\pcl_io.dir\src\ascii_io.cpp.obj /Fdio\CMakeFiles\pcl_io.dir\ /FS -c C:\software\pcl\src\io\src\ascii_io.cpp
C:\software\pcl\src\common\include\pcl/pcl_macros.h(83): warning C4067: unexpected tokens following preprocessor directive - expected a newline
C:\software\pcl\src\common\include\pcl/point_types.h(810): error C3536: 'pcl::traits::has_xy_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(813): error C3536: 'pcl::traits::has_xy_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(826): error C3536: 'pcl::traits::has_xyz_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(829): error C3536: 'pcl::traits::has_xyz_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(843): error C3536: 'pcl::traits::has_normal_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(846): error C3536: 'pcl::traits::has_normal_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(857): error C3536: 'pcl::traits::has_curvature_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(860): error C3536: 'pcl::traits::has_curvature_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(871): error C3536: 'pcl::traits::has_intensity_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(874): error C3536: 'pcl::traits::has_intensity_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(886): error C3536: 'pcl::traits::has_color_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(889): error C3536: 'pcl::traits::has_color_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(900): error C3536: 'pcl::traits::has_label_v<PointT>': cannot be used before it is initialized
C:\software\pcl\src\common\include\pcl/point_types.h(903): error C3536: 'pcl::traits::has_label_v<PointT>': cannot be used before it is initialized
ninja: build stopped: subcommand failed.  

Environment :

  • OS: Windows 10 with MSVC 2015 Update 3
  • Compiler: Microsoft Visual Studio 14.0
  • PCL Version: from v1.10.0
  • PCL Type: Installed/Compiled from source
  • GPU, Kinfu, CUDA enabled? No
  • List and Version of dependencies used : Boost 1.66, Eigen 3.3.7, QHull master, Flann 1.9.1

Possible Solution

Easy but unclean solution is to remove these constexpr declarations and use directly the necessary values in the template declarations.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions