Re: how to detect the compile is 32 bits or 64 bits?



steve yee wrote:
i want to detect if the compile is 32 bits or 64 bits in the source
code itself. so different code are compiled respectively. how to do
this?

You invite bugs, as well as taking the question off the topic of standard C, if you write source code which has to change. The usual question is about (sizeof)<various pointer types>. If your question is simply about (sizeof)int, you create problems by assuming it is determined by whether you have a 32- or 64-bit platform. If you insist on unions of pointers and ints, knowing whether it is 32 or 64 bits won't save you. More so, if you are one of those who writes code which depends on (sizeof)(size_t x).
.