AM_CONDITIONAL测试类型的大小

时间:2013-04-20 22:41:30

标签: autoconf automake

如果PLATFORM64等于8,我想定义SIZEOF_VOIDP,下面的配置代码段不起作用,但会显示我想要实现的内容。有没有办法在我的配置脚本中执行此操作?

# Get size of void*
AC_CHECK_SIZEOF(void*)

# Determine if this is a 32 or 64 bit system, this can also be set manually with "-DPLATFORM64"
AM_CONDITIONAL([PLATFORM64], [test SIZEOF_VOIDP = 8])

更新

我试过了:

AM_CONDITIONAL([PLATFORM64], [test "$SIZEOF_VOIDP" -eq 8])

但我得到了#34;测试:错误号码"错误信息。

1 个答案:

答案 0 :(得分:0)

问题是AC_CHECK_SIZEOF正在定义预处理程序指令,而不是设置shell变量。您可以在致电$host_cpu后尝试测试AC_CANONICAL_HOST

可替换地:

AC_PREPROC_IFELSE([AC_LANG_SOURCE([
#if SIZEOF_VOIDP != 8
#error
#endif
])], [platform64=true], [platform64=false])

AM_CONDITIONAL([PLATFORM64], [test "$platform64" = true])