Re: [轉錄][問題] 程式碼一樣 2台電腦跑出來不一樣

看板NTUGIEE_EDA作者 (gwliao)時間20年前 (2006/02/19 15:02), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串5/6 (看更多)
※ 引述《yellowfishie (喵喵喵喵~~~)》之銘言: : 找到了,是變數沒有 initialize 初始值, : 所以不同的機器會給不同的值,跑出來就不相同了 :) 可以對你比中指嗎? #-_- : 推 Donnie:加 -Wall 就找的到了 02/18 17:05 -Wall是compiling time很好用的參數 :) 不過也是因為只能在compileing time有用, 所以後人才發展Valgrind. Valgrind是針對running time來找bug. : 推 nextme:ㄟ..... 請問一下 -Wall是什麼呀? 02/18 17:29 是蓋牆壁的意思, gcc會教你蓋牆壁. : 推 moonshade:warning all 02/18 22:43 : 推 yellowfishie:它是 class 裡的變數,wall 不會警告 02/18 23:03 抓memory相關的問題, 推薦用Valgrind. http://valgrind.org/ Valgrindk有這些功能: Memcheck: * Use of uninitialised memory * Reading/writing memory after it has been free'd * Reading/writing off the end of malloc'd blocks * Reading/writing inappropriate areas on the stack * Memory leaks -- where pointers to malloc'd blocks are lost forever * Mismatched use of malloc/new/new [] vs free/delete/delete [] * Overlapping src and dst pointers in memcpy() and related functions Addrcheck: is a lightweight version of Memcheck. programs run about twice as fast as they do on Memcheck, and a lot less memory is used. ( 對, Memcheck很慢很慢.....zzzzZZZZZ ) Cachegrind: is a cache profiler. Helgrind: finds data races in multithreaded programs. 後面兩個應該很少有機會用到. 所以就不貼太多message了. 不過一開始的錯誤訊息會讓你退卻, 因為錯誤太多了...感覺自己的程式像未爆蛋一樣. ( 我就是退卻的人之一, 真的很多 Orz ) 最後......Valgrind只支援Linux. Sun? 忘了它吧. XD The Valgrind 3.0.X series supports the following platforms. * x86/Linux: support is mature and almost complete. * AMD64/Linux: support is new but fairly complete. * PPC32/Linux: support is new, incomplete, but improving. You must be running Linux kernel 2.4.X, 2.5.X or 2.6.X, and glibc 2.2.X, 2.3.X or 2.4.X. That covers the vast majority of installed systems at present. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.230.125
文章代碼(AID): #13-1WA_x (NTUGIEE_EDA)
討論串 (同標題文章)
文章代碼(AID): #13-1WA_x (NTUGIEE_EDA)