QT編譯失敗,但是理論上卻沒有什麼語法錯誤,莫名其妙的錯誤QT syntax error :missing ';' before '*'

報錯如下:

首先在報錯語句沒有語法錯誤,但是就是報錯,爲什麼這樣呢?以下是一種原因

 是因爲頭文件的循環包含。

patientinterface.h文件

  PatientInterfaceInformation *uiinformation;報錯,但是這裏是沒有語法錯誤。

原因:PatientInterfaceInformation類是在其他地方定義的,因此需要包含這個頭文件

#include "Patient/patientinterfaceinformation.h"

但是,"Patient/patientinterfaceinformation.h"文件中,意外在裏面添加了#include "Patient/patientinterface.h",這樣,在加載時,不斷的循環包含,導致報錯。

解決方案提示來源:https://stackoverflow.com/questions/19060039/qt-c-c2143-syntax-error-missing-before

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章