C++ 在gcc 4.1.2上Boost进程间失败
我正在尝试使用Boost::Interprocess,但在尝试使用GCC4.1.2进行编译时,出现了一些编译器错误。我缩小了代码的范围,并设法在没有boost的情况下重现问题。代码是:C++ 在gcc 4.1.2上Boost进程间失败,c++,templates,gcc,C++,Templates,Gcc,我正在尝试使用Boost::Interprocess,但在尝试使用GCC4.1.2进行编译时,出现了一些编译器错误。我缩小了代码的范围,并设法在没有boost的情况下重现问题。代码是: #include <iostream> static const std::size_t offset_type_alignment = 0; template<class T, class U> struct pointer_to_other; template<class T
#include <iostream>
static const std::size_t offset_type_alignment = 0;
template<class T, class U>
struct pointer_to_other;
template<class T, class U, template<class> class Sp>
struct pointer_to_other< Sp<T>, U >
/*144*/{
typedef Sp<U> type;
};
template <class PointedType, class DifferenceType, class OffsetType, std::size_t OffsetAlignment>
class offset_ptr
{
};
template <class T, class DifferenceType = std::ptrdiff_t, class OffsetType = std::size_t, std::size_t Alignment = offset_type_alignment>
class offset_ptr;
template<class T, class T2, class T3, std::size_t A, class U>
/*158*/struct pointer_to_other<offset_ptr<T, T2, T3, A>, U >
{
typedef offset_ptr<U, T2, T3, A> type;
};
template<class VoidPointer>
class message_queue_t
{
typedef VoidPointer void_pointer;
/*167*/ typedef typename pointer_to_other<void_pointer, char>::type char_ptr;
};
int main()
{
/*177*/ message_queue_t< offset_ptr<void, std::ptrdiff_t, std::size_t, offset_type_alignment> > test;
}
#包括
静态常量标准::大小偏移类型对齐=0;
模板
指向其他对象的结构指针;
模板
指向其他对象的结构指针
/*144*/{
typedef-Sp型;
};
模板
类偏移量
{
};
模板
类偏移量;
模板
/*158*/struct指针指向其他
{
typedef offset_ptr类型;
};
模板
类消息队列
{
typedef VoidPointer void_指针;
/*167*/typedef typename指针指向其他::type char\u ptr;
};
int main()
{
/*177*/消息队列测试;
}
我得到的错误是:
.cc:在的实例化中
消息队列>
.cc:177:从此处实例化
.cc:167:错误:类模板不明确
结构指针指向其他对象的实例化,char>
.cc:144:错误:
候选对象是:结构指针指向其他对象,U>
.cc:158:错误:结构
指向其他对象的指针,U>
.cc:167:错误:未定义类型的使用无效
–指向其他对象的结构指针,char>
.cc:140:错误:声明–struct
指向其他对象的指针,
char>
在MSV中,这可以很好地编译。编译也很好,但它使用了GCC4.3.4
重要
- 更改编译器是不可能的
- 我知道Boost::Interprocess没有使用此版本的gcc进行测试
message_queue_t< offset_ptr<void, std::ptrdiff_t, std::size_t, offset_type_alignment> > test;
消息队列测试;
为了使它工作?这是一个编译器限制。它根本不受支持 这是编译器的限制。它根本不受支持 你能添加一个证实这个限制的来源吗?@nikhil whoa这是一年多以前的事了,我几乎不记得我在问什么,更不记得我是如何得出这个结论的。哦,好吧,我也被类似的问题困扰了。你能添加一个证实这个限制的来源吗?@nikhil whoa这是一年多以前的事了,我几乎不记得我在问什么,更不用说我是如何得出这个结论的了。哦,好吧,我也被类似的问题困扰了。