检测CPU架构编译时 [英] Detecting CPU architecture compile-time
问题描述
在编译C或C ++代码时,找出CPU体系结构的最可靠方法是什么?据我所知,不同的编译器有自己的一套非标准预处理器定义( _M_X86
in MSVS, __ i386 __
, __ arm __
在GCC等)。
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).
是否有标准检测我正在建设的架构?如果没有,是否有一个来源为各种编译器的这样的定义的完整列表,如标题所有样板 #ifdef
s?
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?
推荐答案
以下是有关预定义的架构宏和其他类型的预定义宏。
Here is some information about Pre-defined Architecture Macros and other types of pre-defined macros.
这篇关于检测CPU架构编译时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!