作者micky64 (micky)
看板C_and_CPP
標題[問題] xcode與Visual Studio結果不同
時間Sat Nov 7 17:51:17 2015
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Xcode & Visual Studio 2010
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
無
問題(Question):
兩者結果不同
VC++:
http://imgur.com/pxTWyMb
Xcode:
http://imgur.com/gAG4F0g
餵入的資料(Input):
lena.bmp (8bits,512*512)
http://imgur.com/o4kWisP
預期的正確結果(Expected Output):
VC++才是預期結果, 用dev c++也是一樣的結果,
但xcode究竟哪裡錯了QQ
錯誤結果(Wrong Output):
如問題處QQ
程式碼(Code):(請善用置底文網頁, 記得排版)
http://codepad.org/6s9RTkek
補充說明(Supplement):
希望有人能幫我解決這問題QQ
不管怎麼重開project, 重開機 都無法變成正確的圖Orz
先謝謝各位Q______Q
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.251.225.175
※ 文章網址: https://webptt.com/m.aspx?n=bbs/C_and_CPP/M.1446889880.A.457.html
1F:→ x000032001: A,B,C,D,E,F,G...................... 11/07 18:26
嗚嗚我知道矩陣設得亂七八糟QQQQQ
但是我有寫註解希望有人能有辦法解決QQQQQ
※ 編輯: micky64 (111.251.225.175), 11/07/2015 18:35:22
2F:推 chubiei: 看code猜測是因為struct大小不同 可以google關鍵字 11/07 20:59
3F:→ chubiei: c attribute packed 11/07 20:59
4F:→ remizu: 建議遇到這類問題時 可以先一步步追蹤值到哪裡不符合預期 11/07 21:12
5F:→ remizu: 樓上說的struct alignment的問題是有可能的 11/07 21:13
6F:推 LiloHuang: 一樣都是 64 bit 的程式,Windows 的 unsigned long 11/07 21:45
7F:→ LiloHuang: 會是 4 bytes,但是在 UNIX-like 下會是 8 bytes 11/07 21:46
8F:→ LiloHuang: 請 #include <stdint.h> 然後改用 uint32_t 來描述 BMP 11/07 21:46
9F:推 LiloHuang: 我相信問題自然就會消失,有興趣可以自己印一下大小 11/07 21:51
10F:推 kwpn: unsigned long全改成uint32_t試試 11/07 23:18
11F:→ kwpn: c,c++讀檔和網路傳輸,最好不要用int,long,char之類的型別啦 11/07 23:20