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

Table of Contents

各位大大好,
小弟手上有支程式如下;

#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 ?

謝謝!

--

All Comments

Tristan Cohan avatarTristan Cohan2008-08-21
gcc -E -dM - < /dev/null 找找看有沒有什麼端倪
Agatha avatarAgatha2008-08-23
應該是寫 Makefile 處理,不是從 compiler 下手。
Andy avatarAndy2008-08-26
man gcc -> -m32 / -m64