Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用qFromBigEndian编译错误_C++_Qt_Templates - Fatal编程技术网

C++ 使用qFromBigEndian编译错误

C++ 使用qFromBigEndian编译错误,c++,qt,templates,C++,Qt,Templates,我试图使用qFromBigEndian从通过udp套接字接收的字节流中读取32位int void processData(uchar *data) { qint32 addr; addr = qFromBigEndian(data); } 编译此文件会出现以下错误: 错误:从'uchar*'到'qint32'的转换无效。 Qt文档说明: T qFromBigEndian(const-uchar*src) 从内存位置src读取一个大端数字,并返回主机字节顺序表示形式中的数字。注意:模板类

我试图使用qFromBigEndian从通过udp套接字接收的字节流中读取32位int

void processData(uchar *data)
{
  qint32 addr;
  addr = qFromBigEndian(data);
}
编译此文件会出现以下错误: 错误:从'uchar*'到'qint32'的转换无效。

Qt文档说明:

T qFromBigEndian(const-uchar*src)

从内存位置src读取一个大端数字,并返回主机字节顺序表示形式中的数字。注意:模板类型T可以是qint16、qint32或qint64。


显然,我在做一些有点愚蠢的事情,我已经羞愧地垂下头来了。有人能解释一下我的明显错误吗?

注意,
qFromBigEndian(const-uchar*src)
是一个函数模板

缺少模板参数,请使用

addr = qFromBigEndian<qint32>(data);
addr=qFromBigEndian(数据);

取而代之的是,一切都会按预期进行。

非常感谢。现在已经分类了。