Detecting CPU architecture compile-time
问题 What is the most reliable way to find out CPU architecture when compiling C or C++ code? As far as I can tell, different compilers have their own set of non-standard preprocessor definitions ( _M_X86 in MSVS, __i386__ , __arm__ in GCC, etc). Is there a standard way to detect the architecture I\'m building for? If not, is there a source for a comprehensive list of such definitions for various compilers, such as a header with all the boilerplate #ifdef s? 回答1: Here is some information about Pre