Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/137.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 确定在预处理器中从64位交叉编译32位的时间?_C++_C Preprocessor - Fatal编程技术网

C++ 确定在预处理器中从64位交叉编译32位的时间?

C++ 确定在预处理器中从64位交叉编译32位的时间?,c++,c-preprocessor,C++,C Preprocessor,我使用的答案是: #ifndef AVUNA_CFG #define AVUNA_CFG #if _WIN32 || _WIN64 #if _WIN64 #define BIT64 #else #define BIT32 #endif #endif // Check GCC #if __GNUC__ #if __x86_64__ || __ppc64__ #define BIT64 #else #define BIT32 #endif #endif #endif 但是,当将-m32指定给GC

我使用的答案是:

#ifndef AVUNA_CFG
#define AVUNA_CFG
#if _WIN32 || _WIN64
#if _WIN64
#define BIT64
#else
#define BIT32
#endif
#endif

// Check GCC
#if __GNUC__
#if __x86_64__ || __ppc64__
#define BIT64
#else
#define BIT32
#endif
#endif
#endif

但是,当将
-m32
指定给GCC进行交叉编译时,这似乎不起作用,因此它总是显示
BIT64
。有什么定义可以用于此目的吗?

我最终使用了Eclipse定义,因为我有两种不同的32/64位交叉编译运行配置。工作正常。

此外,对于gcc,请查看检测64位编译的
\uuuu LP64\uuuu
\u LP64
:“如果(且仅当)编译针对的是长int和指针都使用64位而int使用32位的目标,则定义这些宏的值为1。”@雷米利博:唯一不同的是,如果有人定义了WIN32 0,那么你建议的代码会更糟。@雷米利博,我认为你不能在预处理器中使用sizeof?@JavaProphet:你是对的。我忘记了那个警告。最近添加的-mx32可能会使这个问题的完整答案更加复杂