c++ - Wheb Build pcl with visual studio 2010 我得到 point_types.hpp(1185) : error C2146: syntax error : missing ';' before identifier 'traits'

标签 c++ visual-studio-2010 point-cloud-library

我在 vs 2010 中使用 PCL 库。我不使用 CMake,我包含所有 dll、库和包含文件夹。

我写了一个简单的程序来填充点云实例中半球的点云。这是我 super 简单的代码:

#include <iostream>
#include <pcl\point_cloud.h>
#include <pcl\impl\point_types.hpp>
#include <cmath>

using namespace pcl;
void AddPointsToCloud(PointCloud<PointXYZRGB>& cloud);

int main ()
{
   PointCloud<PointXYZRGB> cloud;

   AddPointsToCloud(cloud);
   return 0;
}




void AddPointsToCloud(PointCloud<PointXYZRGB>& cloud)
{
    double R =2;
    int nTheta = 20; //number of grid points
    double dTheata =  0.5*M_PI / (nTheta - 1);

    int nPhi = 20;
    double dPhi =  2 * M_PI / (nPhi - 1);

    for (int i = 0 ; i < nTheta ; i++ )
    {
       for (int j = 0 ; j < nPhi ; j++)
       {
          double x = R * sin(i*dTheata) * cos(j* dPhi );
          double y = R * sin(i*dTheata) * sin(j* dPhi );
          double z = R * cos(i*dTheata);

          PointXYZRGB p;
          p.x = x;
          p.y = y;
          p.z = z;

          p.r = static_cast<uint8_t>(255 * x / R);
          p.g = static_cast<uint8_t>(255 *  y / R);
          p.b = static_cast<uint8_t>(255 * z / R);


          cloud.push_back(p);
      }
   }
 }

现在,当我在 visual studio 2010 中构建时,出现以下错误:

Error 2 error C2146: syntax error : missing ';' before identifier 'traits' c:\program files (x86)\pcl 1.6.0\include\pcl-1.6\pcl\impl\point_types.hpp 1185

Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files (x86)\pcl 1.6.0\include\pcl-1.6\pcl\impl\point_types.hpp 1185

Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files (x86)\pcl 1.6.0\include\pcl-1.6\pcl\impl\point_types.hpp 1185

我不明白为什么,在构建项目之前我没有任何编译错误,一切都是
在point_types.hpp(pcl头文件)中正确

请帮帮我

提前谢谢你

最佳答案

我能够简化您的代码以解决错误。下面的代码导致我的编译器出错(这是 GCC,但错误与你的相同声明 - traits):

您是否尝试进一步简化代码?

#include <pcl/point_cloud.h>
#include <pcl/impl/point_types.hpp>
int main ()
{
   return 0;
}

查看在 PCL 中使用 point_types.hpp 的示例 - 没有直接使用它的示例。取而代之的是,在包含它之前,还需要设置一些其他的东西。参见示例:Adding your own custom PointT type

那里的最后一个代码示例包含以下内容:

#include <pcl/point_types.h>

point_cloud.hpp 通过以下 include 包含在 point_cloud.h 中(因此不需要包含在您的应用程序中):

#include <pcl/impl/point_types.hpp>  // Include struct definitions

关于c++ - Wheb Build pcl with visual studio 2010 我得到 point_types.hpp(1185) : error C2146: syntax error : missing ';' before identifier 'traits' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19220470/

相关文章:

c++ - 使用已知模型系数在 pcl 中绘制多条线

c# - .NET 和 PCL(点云库)

c++ - 如何在 SWIG 中包装使用引用自定义类型的 C++ 函数?

c++ - 普通 C 加载 C# dll

c++ - 寻找最大数 Qt

c# - Web 服务的 WSDL 中禁止的 XML 架构构造

c++ - 如何计算云中每个点的法线

c++ - 避免基于作为模板参数的函数的返回值的分支

c++ - 如何重新导出 CLR c++ 静态库

visual-studio-2010 - VS2010 F# Smart Tag 添加开放导入声明