It depends on what you mean by "64 bit machine". There are broadly three categories depending on processor family:
- Supports some 64-bit math operations
- Can run programs in X-64 mode (64-bit addressing)
- Has 64-bit kernel support
I assume that you mean sense "2" here, since that s the most relevant for application code. You don t have to worry about sense "1" unless you need to run on older PowerPC Macs, I believe.
You specifically mentioned doing this in C code, which doesn t actually make much sense. If you re compiling C code, you can just build your application "fat", with 32- and 64- bit variants, and therefore do the check at compile-time with:
#if _LP64
//64-bit stuff
#else
//32-bit stuff
#endif