簡體   English   中英

使用qFromBigEndian編譯錯誤

[英]compile error using qFromBigEndian

我正在嘗試使用qFromBigEndian從通過udp套接字接收的字節流中讀取32位int。

void processData(uchar *data)
{
  qint32 addr;
  addr = qFromBigEndian(data);
}

編譯它會出現以下錯誤: 錯誤:從'uchar *'到'qint32'的轉換無效

Qt文檔說:

T qFromBigEndian(const uchar * src)

Reads a big-endian number from memory location src and returns the number in the host byte order representation. Note: Template type T can either be a qint16, qint32 or qint64.

顯然我做的事情有點傻,而且我已經羞愧地垂頭喪氣了。 有人可以解釋一下我明顯的錯誤嗎?

請注意, qFromBigEndian(const uchar *src)是一個函數模板。

您缺少模板參數,請使用

addr = qFromBigEndian<qint32>(data);

相反,事情將按預期工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM