藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年6月6日 10:18


AUPE 8-4的錯誤?

20 if(wait(&status) != pid) /* wait for child */
21 err_sys("wait error");
22 pr_exit(status); /* and print its status */
23 if( ( pid = fork()) <0)
24 err_sys("fork error");
25 else if(pid == 0) /* child */
26
27 status /= 0; /* divide by 0 generate SIGFPE */
28
以下是gcc -c 的結果?
# gcc -c 8-4.c
8-4.c: In function `main':
8-4.c:27: warning: division by zero
# new 8-4 《---------------------- 自命名的new就是gcc,用了它就能是用AUPE作者自編的函數了。
gcc 8-4.o -lourhdr -o 8-4
/usr/bin/ld: cannot find -lourhdr
collect2: ld returned 1 exit status
make: *** [8-4] Error 1
#

請大家指教!!錯在哪裡?  :)  :)

AUPE 8-4的錯誤?

錯誤提示已經很明顯了,一個是不能用0作除數,如果為了引發一個信號,故意這樣做,那就用1-1來代替0。另一個是-lourhdr位置不正確,放到命令行的最後去看看。

AUPE 8-4的錯誤?

用1-1不行吧?編譯器編譯時能把常數運算換算為最終結果,仍然會報不能被0除。
書名是APUE不是AUPE吧。advanced programming of Unix environment

AUPE 8-4的錯誤?

那就int b=1; 用b-1代替0好了。



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com