As title says, is there any elegant and safe way to determine if architecture is 32bit or 64bit. By elegant, you can think of precise, correct, short, clean, and smart way.
If you are using GCC (as indicated in the tags), you can test, as a compile-time test
#if __SIZEOF_POINTER__ == 8
to find out whether it's a 64-bit system. Make sure the GCC version you are using defines __SIZEOF_POINTER__ at all before using it.
__SIZEOF_POINTER__