【发布时间】:2015-02-17 16:37:33
【问题描述】:
有没有比将 CFLAGS 设置为“-Werror -Wimplicit-function-declaration”更好的方法来为丢失的原型编写 autoconf 测试?
具体来说,我正在尝试确定是否需要提供我自己的pwrite(2)
和pread(2)。如果环境是严格的,则不定义 pread/pwrite。
这是我现在所拥有的,它有效:
AC_INIT([pwrite],[0.0.0],[none],[nothing],[nowhere])
AC_CONFIG_HEADERS([config.h])
old_CFLAGS=$CFLAGS
CFLAGS="-Werror $CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
int main(int argc, char **argv) {
int ret = pwrite(99, "blah", 1, 0);
return 0;
} ]) ],
AC_MSG_RESULT([using system pwrite prototype])
AC_DEFINE(HAVE_PWRITE, 1, [pwrite protoype exists]),
AC_MSG_RESULT([no pwrite protoype. using our own])
)
CFLAGS=$old_CFLAGS
AC_OUTPUT()
当我这样做时,configure CFLAGS=-std=c99 确实会检测到 pwrite 是隐式声明的,而仅configure 就会在 unistd.h 中找到一个 pwrite 原型。但是,在 configure 中使用 CFLAGS 似乎不是“autoconf-y”的方式来做到这一点。
【问题讨论】:
标签: autoconf