如何在編譯程式時得知 linux 為 32/64 bit os

看板Linux作者 (linux藍海帝國)時間17年前 (2008/08/17 18:51), 編輯推噓3(300)
留言3則, 3人參與, 最新討論串1/1
各位大大好, 小弟手上有支程式如下; #define using_64_bit_os #ifdef using_64_bit_os #define vsize 8 #else #define vsize 4 #endif 每次在編譯時, 都要根據不同的系統版本 (linux fedora 9 i686/X86_64) 去手動開關這個define: #define using_64_bit_os 有沒有自動化的方式呢, 讓 compiler 自行判斷現在的 os 跑 32 or 64 bits ? 謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.216.169.121

08/17 19:10, , 1F
gcc -E -dM - < /dev/null 找找看有沒有什麼端倪
08/17 19:10, 1F

08/17 21:43, , 2F
應該是寫 Makefile 處理,不是從 compiler 下手。
08/17 21:43, 2F

08/17 22:30, , 3F
man gcc -> -m32 / -m64
08/17 22:30, 3F
文章代碼(AID): #18g0B0_L (Linux)
文章代碼(AID): #18g0B0_L (Linux)