作者chhsiao (bye~)
看板b96902HW
標題Re: [使徒] 問題
時間Mon Dec 3 17:21:30 2007
※ 引述《olala7846 (金剛阿含)》之銘言:
: source.c: In function `main':
: source.c:25: warning: suggest parentheses around assignment used as truth
: value
: source.c:41: warning: suggest parentheses around assignment used as truth
: value
: source.c:62: warning: suggest parentheses around assignment used as truth
: value
: source.c:77: warning: suggest parentheses around assignment used as truth
: value
: 匹改妞不爽了
: 但是他給我六分
: 這怎樣?
: 我的25行是
: while(temptr=strstr(temptr,a_HREF)){
: }
現在批改娘的 compiler 加了 -Wall 參數 (其實改好一陣了),
-Wall 意思是 Warning all, 把所有的 compiler 警告選項打開,
不管是不合標準但 compiler 可接受的程式碼,
還是合乎語法但 compiler 認為可能有問題的程式碼
(例如 compiler 可能從語法猜出變數可能沒初始化, 或是型態可能有問題)
都會給警告.
上面的意思是, while 裡面應該要放個 "普通" 的真假判斷句,
放 = (assignment) 雖然也合乎語法, 可是可能是打錯, 因為一般不會這樣寫,
所以 compiler 就給警告了.
如果要跟 compiler 保證我就是要這樣寫, compiler 建議你可以寫成
while(
(temptr=strstr(temptr,a_HREF)
))
BTW, warning 跟 error 的差別在於:
warning 的語法合乎標準, 或是至少還可以解讀出來,
因此 compiler 可以 compile 完畢並產生 exe;
error 是語法完全錯亂, 因此 compiler 太笨而看不懂.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.46
※ 編輯: chhsiao 來自: 140.112.30.46 (12/03 17:21)
1F:推 s90413k64:把=改成==看看 12/03 18:18
2F:→ purincess:while((temptr=strstr(temptr,a_HREF))==NULL)更好懂XD 12/03 19:07
3F:推 chhsiao:回一樓, olala 是想用 = 吧 12/03 19:08
4F:推 BNMAA:乾脆再加上 -Wextra -pedantic @@" 12/03 19:10
5F:→ BNMAA:貳樓應該是 != NULL 吧!? 12/03 19:13
6F:→ purincess:嘿 對 是 != 不好意思我頭昏了..||| 12/03 20:29
7F:推 olala7846:謝謝助教 12/03 23:59