class FixedDataBlock: public DataBlockHeaderCommon<BlockSize>
{
// Construction
public:
FixedDataBlock(void* pool, SizeT const entrySize, SizeT const alignment)
: base_t(eBlkFixData, pool)
{
this_t* dummy = reinterpret_cast<this_t*>(0);
// offsets is a type of uint16_t
OffsetT dataStartBlockOffset = reinterpret_cast<OffsetT>( &dummy->data[0] );
}
// Member variables
private:
int8_t data[ BlockSize-sizeof(header_t) ];
};
错误:无效的类型转换:将“ int8_t = {signed char} *”转换为“ uint16_t = {unsigned short}”
OffsetT dataStartBlockOffset = reinterpret_cast(&dummy-> data [0]);
// dummy-> data [0]被签名为char *,而dataStartBlockOffset为未签名的短符号
上面的代码在Windows上编译正常,但仅在GCC上失败。