星期三, 3月 29, 2006

!!! a bad example on code guard !!

build一個project,卻出現..
trygfx.cpp:7: parse error before `}'

所以?問題是在那?
依照經驗,朝上面找....#include XXX.h

到XXX.h去看..果然
#define NOT_COMPIL }}}}}}not}}}}}compilable}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
看看header comment。暈倒。
就是這個結尾導致include他的code有error。

這是 很不好的設計方法,讓compiler 的error message顯示出不正確的資訊。
應該要echo 一個message出來。
或是 在後面直接產生error.



解決 : 在include之前要define ALLOW_XX_CODE

trace的步驟: 寫一個一的file,從發生問題的header開始include起。build。ok include上一層。
"層"是從最初make output error的message取得的,都會有
from xxxxxxxx.c : 77
from xxxxxxx.c:99
include xxxxxx.h line lll error:dsdsdsd
就是那個"from"可以trace include的hirachy

解決這個code後,接著就是link : undefine reference to `xxxxxx` 的問題。
這個就是找到`xxxxx`所在的library,加到link library就可以。
OK!!!

....trygfx 順利的在lcd畫出一個白色方塊....

沒有留言:

網誌存檔