本帖最后由 Jacklee 于 2017-11-25 11:38 编辑
为了实现数组内36bits的数据解析出double类型,定义了以下联合并使用了64bits空间的long long作联合,函数定义:
[mw_shl_code=cpp,true]double cmpPSR(u8 *buf,u16 offest) //cmpPSR-36bit
{
union m_int64
{
long long m_out;
u8 m_in[8];
}Ipsr;
Ipsr.m_in[0]=buf[offest];
Ipsr.m_in[1]=buf[offest+1];
Ipsr.m_in[2]=buf[offest+2];
Ipsr.m_in[3]=buf[offest+3];
Ipsr.m_in[4]=buf[offest+4];
Ipsr.m_in[5]=buf[offest+5];
Ipsr.m_in[6]=buf[offest+6];
Ipsr.m_in[7]=buf[offest+7];
long long ipsr;
ipsr = Ipsr.m_out>>28;
return (double)ipsr/128.0;
}[/mw_shl_code]
编译在long long ipsr定义位置报错:
error: #268: declaration may not appear after executable statement in block
long long ipsr;
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>