Я попытался определить свой собственный тип PointT, чтобы дать мне XYZRGBA и значения интенсивности в одной точке. Я попытался выполнить соглашения, изложенные в этой статье на веб-сайте библиотеки облачных облаков: http://pointclouds.org/documentation/tutorials/adding_custom_ptype.phpКак узнать, что делает неполный тип незавершенным для ошибки: арифметика на указателе на неполный тип
Реализация для PointXYZRGBAI находится в файле .CPP для одного из моих классов, но я пересылаю его в файле заголовка, который является включая другие файлы заголовков. Реализация в LidarFile.cpp:
struct PointXYZRGBAI{
PCL_ADD_POINT4D;
union{
struct{
float intensity;
uint32_t rgba;
};
float data_c[4];
};
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
} EIGEN_ALIGN_16;
POINT_CLOUD_REGISTER_POINT_STRUCT(PointXYZRGBAI,
(float, x, x)
(float, y, y)
(float, z, z)
(float, intensity, intensity)
(uint32_t, rgba, rgba)
)
inline std::ostream& operator << (std::ostream& os, const PointXYZRGBAI& p){
os << "(" << p.x << ", " << p.y << ", " << p.z << " - " << p.intensity << " - " << p.rgba << ")";
return (os);
}
и опережающее объявление находится внутри имени файла заголовка PointXYZRGBAI.h
#define PCL_NO_PRECOMPILE
#ifndef POINTXYZRGBAI_H
#define POINTXYZRGBAI_H
#endif
#include <pcl/point_types.h>
struct PointXYZRGBAI;
inline std::ostream& operator << (std::ostream& os, const PointXYZRGBAI& p);
С моей очень общее представление о структурах, мне нужно направить объявить-структуру так что компилятор понимает, что PointXYZRGBAI действительно является структурой, а не некоторым неизвестным типом во время компиляции, а затем заполняет пробелы с фактической реализацией. Но это, по-видимому, оспаривается тем фактом, что когда я объявляю любую переменную-экземпляр участника, которая использует шаблонный тип PointXYZRGBAI, возникает ошибка: арифметика на указателе на неполный тип «PointXYZRGBAI», например, когда я объявляю облако точек, которое использует структуру PointXYZRGBAI:
pcl::PointCloud<PointXYZRGBAI> cl; //Error: arithmetic on a pointer to an incomplete type 'PointXYZRGBAI'
//__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
// __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
Казалось бы, что существуют неопределенные операции, происходящие от типа PointXYZRGBAI. И что же мне делать? Нужно ли каким-либо образом реализовать структуру перед заголовком LidarFile.h? Для справки, вот полная ошибка стека ошибок:
In file included from /Users/wfehrnstrom/Demeter/core.cpp:9:
In file included from /usr/local/include/boost/thread/thread.hpp:12:
In file included from /usr/local/include/boost/thread/thread_only.hpp:17:
In file included from /usr/local/include/boost/thread/pthread/thread_data.hpp:24:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:424:68: error:
arithmetic on a pointer to an incomplete type 'PointXYZRGBAI'
__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
^~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:368:29: note:
in instantiation of member function
'std::__1::__vector_base<PointXYZRGBAI,
Eigen::aligned_allocator_indirection<PointXYZRGBAI> >::__destruct_at_end'
requested here
void clear() _NOEXCEPT {__destruct_at_end(__begin_);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:451:9: note:
in instantiation of member function
'std::__1::__vector_base<PointXYZRGBAI,
Eigen::aligned_allocator_indirection<PointXYZRGBAI> >::clear' requested
here
clear();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iterator:1244:75: note:
in instantiation of member function
'std::__1::__vector_base<PointXYZRGBAI,
Eigen::aligned_allocator_indirection<PointXYZRGBAI> >::~__vector_base'
requested here
...<class _Tp, class _Alloc> friend class _LIBCPP_TYPE_VIS_ONLY vector;
^
/Users/wfehrnstrom/Demeter/LidarFile.h:20:7: note: in instantiation of member
function 'pcl::PointCloud<PointXYZRGBAI>::~PointCloud' requested here
class LidarFile{
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1527:14: note:
in instantiation of function template specialization
'std::__1::allocator_traits<std::__1::allocator<LidarFile>
>::__destroy<LidarFile>' requested here
{__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:424:25: note:
in instantiation of function template specialization
'std::__1::allocator_traits<std::__1::allocator<LidarFile>
>::destroy<LidarFile>' requested here
__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:368:29: note:
in instantiation of member function 'std::__1::__vector_base<LidarFile,
std::__1::allocator<LidarFile> >::__destruct_at_end' requested here
void clear() _NOEXCEPT {__destruct_at_end(__begin_);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:451:9: note:
in instantiation of member function 'std::__1::__vector_base<LidarFile,
std::__1::allocator<LidarFile> >::clear' requested here
clear();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iterator:1244:75: note:
in instantiation of member function 'std::__1::__vector_base<LidarFile,
std::__1::allocator<LidarFile> >::~__vector_base' requested here
...<class _Tp, class _Alloc> friend class _LIBCPP_TYPE_VIS_ONLY vector;
^
/Users/wfehrnstrom/Demeter/PointXYZRGBAI.h:9:8: note: forward declaration of
'PointXYZRGBAI'
struct PointXYZRGBAI;
^
In file included from /Users/wfehrnstrom/Demeter/core.cpp:9:
In file included from /usr/local/include/boost/thread/thread.hpp:12:
In file included from /usr/local/include/boost/thread/thread_only.hpp:17:
In file included from /usr/local/include/boost/thread/pthread/thread_data.hpp:24:
Любая помощь или разъяснение были бы очень признательны.
Не зная, что такое шаблон 'pcl :: PointCloud', наиболее вероятным ответом является то, что этот шаблон пытается создать экземпляр класса его параметров или использовать его каким-то образом, что требует определения класса. –
A ** type ** - * указанный *. Его ** члены ** * реализованы *. Объявите свою структуру в заголовке. – Nelfeal
Да! Или приращение/уменьшение/вычитание указателей: поскольку размер должен быть известен – Christophe