1. 程式人生 > >invalid use of incomplete type struct 或者是class的解決辦法

invalid use of incomplete type struct 或者是class的解決辦法

最近在移植wifi display的程式碼,過程中遇到一些問題,有些問題是常見的問題,現列出解決方法自己mark一下,也希望能對別人有所幫助,少走彎路。

常見問題一:invalid use of incomplete type

出現這個問題,表明編譯器不知道所用的struct 或者是class的具體實現,通常出現在如下情況:假設我們有一個class some定義在some.h中,實現在some.cpp中,我們在other.cpp中要用到這個some 的方法,於是我們再other.h中宣告可一個class some,並聲明瞭要用到的方法,這樣就會導致上述的問題,解決這個問題的方法是:在other.cpp中include some.h,這樣編譯器就會根據該標頭檔案找到class some的具體定義,問題也就解決了。