尝试编译代码时出现不完整的类型错误。我知道它与includes有关,但我的项目很大,它使用了几个模板,所以我找不到哪个类型实际上是不完整的。错误消息也无济于事:
Compiling: ../../../addons/ofxTableGestures/src/Graphics/objects/CursorFeedback.cpp
In file included from ../../../addons/ofxTableGestures/ext/boost/fusion/include/invoke_procedure.hpp:10,
from ../../../addons/ofxTableGestures/src/oscGestures/tuioApp.hpp:46,
from /home/thechaos/Projectes/of_preRelease_v0061_linux_FAT/addons/../apps/OF-TangibleFramework/ofxTableGestures/src/Graphics/objects/CursorFeedback.hpp:35,
from /home/thechaos/Projectes/of_preRelease_v0061_linux_FAT/addons/../apps/OF-TangibleFramework/ofxTableGestures/src/Graphics/objects/CursorFeedback.cpp:31:
../../../addons/ofxTableGestures/ext/boost/fusion/functional/invocation/invoke_procedure.hpp: In function ‘void boost::fusion::invoke_procedure(Function, const Sequence&) [with Function = void (tuio::CanBasicFingers<Graphic>::*)(long int, float, float, float, float, float), Sequence = boost::fusion::joint_view<boost::fusion::joint_view<boost::fusion::iterator_range<boost::fusion::vector_iterator<const boost::fusion::vector6<long int, float, float, float, float, float>, 0>, boost::fusion::vector_iterator<boost::fusion::vector6<long int, float, float, float, float, float>, 0> >, const boost::fusion::single_view<tuio::CanBasicFingers<Graphic>*> >, boost::fusion::iterator_range<boost::fusion::vector_iterator<boost::fusion::vector6<long int, float, float, float, float, float>, 0>, boost::fusion::vector_iterator<const boost::fusion::vector6<long int, float, float, float, float, float>, 6> > >]’:
../../../addons/ofxTableGestures/src/oscGestures/tuioApp.hpp:122: instantiated from ‘void tuio::AlternateCallback<C, M, E>::run(tuio::TEvent*) [with C = tuio::CanBasicFingers<Graphic>, M = void (tuio::CanBasicFingers<Graphic>::*)(long int, float, float, float, float, float), E = tuio::TeventBasicFingersMoveFinger]’
/home/thechaos/Projectes/of_preRelease_v0061_linux_FAT/addons/../apps/OF-TangibleFramework/ofxTableGestures/src/Graphics/objects/CursorFeedback.cpp:64: instantiated from here
../../../addons/ofxTableGestures/ext/boost/fusion/functional/invocation/invoke_procedure.hpp:88: error: incomplete type ‘boost::fusion::detail::invoke_procedure_impl<void (tuio::CanBasicFingers<Graphic>::*)(long int, float, float, float, float, float), const boost::fusion::joint_view<boost::fusion::joint_view<boost::fusion::iterator_range<boost::fusion::vector_iterator<const boost::fusion::vector6<long int, float, float, float, float, float>, 0>, boost::fusion::vector_iterator<boost::fusion::vector6<long int, float, float, float, float, float>, 0> >, const boost::fusion::single_view<tuio::CanBasicFingers<Graphic>*> >, boost::fusion::iterator_range<boost::fusion::vector_iterator<boost::fusion::vector6<long int, float, float, float, float, float>, 0>, boost::fusion::vector_iterator<const boost::fusion::vector6<long int, float, float, float, float, float>, 6> > >, 7, true, false>’ used in nested name specifier
如果我将冲突代码复制到同一个文件,我可以编译它。所以我知道代码本身是正常的,问题是我实例化它的方式。
如何追踪此错误的来源?有没有办法获得c ++编译器和预处理器的跟踪以获得更多信息?
编辑:我正在使用gcc 4.4.1
答案 0 :(得分:3)
如果你给我们编译器会更容易。
在gcc
上,您可以使用-E
选项查看预处理文件。如果您尝试编译预处理文件,它应该更容易诊断。此外,您将确切地了解所涉及的类型。
至于具体错误,最后一行通常是指示性的:
boost::fusion::detail::invoke_procedure_impl<
void (tuio::CanBasicFingers<Graphic>::*)
(long int, float, float, float, float, float),
const boost::fusion::joint_view<
boost::fusion::joint_view<
boost::fusion::iterator_range<
boost::fusion::vector_iterator<
const boost::fusion::vector6<long int, float, float, float, float,
float>,
0
>,
boost::fusion::vector_iterator<
boost::fusion::vector6<long int, float, float, float, float, float>,
0
>
>,
const boost::fusion::single_view< tuio::CanBasicFingers<Graphic>* >
>, // joint_view
boost::fusion::iterator_range<
boost::fusion::vector_iterator<
boost::fusion::vector6<long int, float, float, float, float, float>, 0
>,
boost::fusion::vector_iterator<
const boost::fusion::vector6<long int, float, float, float, float,
float>,
6
>
> // iterator_range
>,
7,
true,
false
>
好的,所以重新格式化有点帮助。
您似乎拥有一个名称空间tuio
,其中应包含一个模板类CanBasicFingers
,您希望使用该Graphic
实例并获取指向成员函数的指针。
假设您已将所有Boost.Fusion
包含权限设置为正确,则可能无法正确包含CanBasicFingers
或Graphic
。
否则,在迭代器的常量中查找mix:使用const和非const迭代器定义范围,这是非常奇怪的。
您应该尝试单独调用它们。
作为诊断的一般技术,我只能推荐Divide And Conquer
方法。你应该尝试逐渐建立表达式:
namespace fusion = boost::fusion;
// First
typedef void (tuio::CanBasicFingers<Graphic>::* function_t)
(long int, float, float, float, float, float);
// Second
typedef fusion::vector6<long int, float, float, float, float, float> vector_t;
// Third: the iterators
typedef fusion::vector_iterator< const vector_t, 0 > const_iterator_begin;
typedef fusion::vector_iterator< const vector_t, 6 > const_iterator_end;
typedef fusion::vector_iterator< vector_t, 0 > iterator_begin;
typedef fusion::vector_iterator< vector_t, 6 > iterator_end;
// Fourth: the ranges
// (which const-ness are oddly messed up)
typedef fusion::iterator_range< const_iterator_begin, iterator_end > range_1;
typedef fusion::iterator_range< iterator_begin, const_iterator_end > range_2;
// Fifth the views
typedef const fusion::single_view<tuio::CanBasicFingers<Graphic>*> single_view;
typedef fusion::joint_view< range_1, single_view > joint_view_internal;
typedef fusion::joint_view< joint_view_internal, range_2 > joint_view_external;
// and here is the final type (aaaah!)
typedef fusion::detail::invoke_procedure_impl<
function_t,
joint_view_external,
7,
true,
false
> procedure_type;
编译此分解形式,应该在更精确的位置产生错误:)
答案 1 :(得分:0)
该类型似乎是(从错误的最后一行):
boost::fusion::detail::invoke_procedure_impl<void (tuio::CanBasicFingers<Graphic>::*)(long int, float, float, float, float, float), const boost::fusion::joint_view<boost::fusion::joint_view<boost::fusion::iterator_range<boost::fusion::vector_iterator<const boost::fusion::vector6<long int, float, float, float, float, float>, 0>, boost::fusion::vector_iterator<boost::fusion::vector6<long int, float, float, float, float, float>, 0> >, const boost::fusion::single_view<tuio::CanBasicFingers<Graphic>*> >, boost::fusion::iterator_range<boost::fusion::vector_iterator<boost::fusion::vector6<long int, float, float, float, float, float>, 0>, boost::fusion::vector_iterator<const boost::fusion::vector6<long int, float, float, float, float, float>, 6> > >, 7, true, false>
这给了我一些我可能怀疑tuio::CanBasicFingers<>
的可能性,因为include链包含tuioApp.hpp。如果在tuioApp.hpp中实例化时尚未定义tuio :: CanBasicFingers,则会出现错误。