作者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