【问题标题】:Solaris and Preprocessor MacrosSolaris 和预处理器宏
【发布时间】:2013-05-13 04:28:08
【问题描述】:

有人会在 Solaris 10 或更高版本的系统上发布cpp -dM < /dev/null 的结果吗?

我无法找到通常定义的预处理器宏。 Solaris 文档没有详细讨论它 [1]、[2],而且 Google 也不是很有帮助。

提前致谢。

【问题讨论】:

  • 如果您使用的是 Solaris Studio 编译器,预定义列表位于 the cc man page 中的 -D 标志下。

标签: macros preprocessor solaris


【解决方案1】:

Solaris 11.1

#define __DBL_MIN_EXP__ (-1021)
#define __FLT_MIN__ 1.17549435e-38F
#define __CHAR_BIT__ 8
#define __WCHAR_MAX__ 2147483647
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __FLT_EVAL_METHOD__ 0
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define __GNUC_PATCHLEVEL__ 3
#define sparc 1
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
#define __unix 1
#define __LDBL_MAX_EXP__ 16384
#define __SCHAR_MAX__ 127
#define __USER_LABEL_PREFIX__ 
#define __STDC_HOSTED__ 1
#define __LDBL_HAS_INFINITY__ 1
#define __DBL_DIG__ 15
#define __FLT_EPSILON__ 1.19209290e-7F
#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
#define __unix__ 1
#define __DECIMAL_DIG__ 36
#define __LDBL_HAS_QUIET_NAN__ 1
#define __GNUC__ 3
#define __DBL_MAX__ 1.7976931348623157e+308
#define __DBL_HAS_INFINITY__ 1
#define __SVR4 1
#define __DBL_MAX_EXP__ 1024
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __sparc__ 1
#define __GXX_ABI_VERSION 1002
#define __FLT_MIN_EXP__ (-125)
#define __DBL_MIN__ 2.2250738585072014e-308
#define __DBL_HAS_QUIET_NAN__ 1
#define __sun 1
#define __REGISTER_PREFIX__ 
#define __NO_INLINE__ 1
#define __FLT_MANT_DIG__ 24
#define __VERSION__ "3.4.3 (csl-sol210-3_4-20050802)"
#define __sparc 1
#define sun 1
#define unix 1
#define __SIZE_TYPE__ unsigned int
#define __ELF__ 1
#define __FLT_RADIX__ 2
#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
#define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MAX_10_EXP__ 38
#define __LONG_MAX__ 2147483647L
#define __FLT_HAS_INFINITY__ 1
#define __PRAGMA_REDEFINE_EXTNAME 1
#define __LDBL_MANT_DIG__ 113
#define __WCHAR_TYPE__ long int
#define __FLT_DIG__ 6
#define __INT_MAX__ 2147483647
#define __FLT_MAX_EXP__ 128
#define __DBL_MANT_DIG__ 53
#define __WINT_TYPE__ long int
#define __LDBL_MIN_EXP__ (-16381)
#define __LDBL_MAX_10_EXP__ 4932
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __sun__ 1
#define __svr4__ 1
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __FLT_MAX__ 3.40282347e+38F
#define __FLT_MIN_10_EXP__ (-37)
#define __GNUC_MINOR__ 4
#define __DBL_MAX_10_EXP__ 308
#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
#define __PTRDIFF_TYPE__ int
#define __LDBL_MIN_10_EXP__ (-4931)
#define __LDBL_DIG__ 33

【讨论】:

  • 这很有趣。 Solaris 及其版本均未出现在转储中。
  • Solaris 传统上使用 #if defined(__sun) && defined(__SVR4) 检测,但现在检查 __SVR4 只有在您需要确保您没有在 20 年前的 SunOS 4 上运行时才有意义。Solaris Studio编译器还定义了一个特定于操作系统版本的宏,例如__SunOS_5_11,但这是 cc 和 CC 传递给预处理器的 -D 标志,而不是 cpp-builtin 值。
  • 没有LP64 定义吗?如何确定主机是 32b 还是 64b Solaris 主机?
  • 系统头文件将定义 _ILP32 或 _LP64 取决于您是否将 -m32 或 -m64(或类似标志)传递给编译器。它不是内置的 cpp,而是标头设置的东西。
  • @jim - 有空的时候请看看How to print preprocessor macros under Sun Studio?。
【解决方案2】:

@jens:

从 Solaris 10 开始的 Sparc 系统始终为 64 位。 X64 系统随 Solaris 10 一起提供,但您仍然可以引导 32 位 x86 内核。

$ isainfo
amd64 i386
$ isainfo -b
64
$ isainfo -v
    64-bit amd64 applications
        avx xsave pclmulqdq aes sse4.2 sse4.1 ssse3 popcnt tscp ahf cx16 sse3 
        sse2 sse fxsr mmx cmov amd_sysc cx8 tsc fpu efs f16c rdrand 
    32-bit i386 applications
        avx xsave pclmulqdq aes sse4.2 sse4.1 ssse3 popcnt tscp ahf cx16 sse3 
        sse2 sse fxsr mmx cmov sep cx8 tsc fpu efs f16c rdrand 

/usr/bin/isainfo 是你的朋友,来自命令行。

从编程的角度来看,检查<sys/feature_tests.h> 中的#defines。你会注意到_LP64 ...

【讨论】:

猜你喜欢
  • 2015-04-15
  • 2017-04-04
  • 2015-07-31
  • 1970-01-01
  • 1970-01-01
  • 2010-09-19
  • 2020-02-09
  • 1970-01-01
相关资源
最近更新 更多