如何使用 configure.ac 包含 AC_INCLUDES_DEFAULT 的内容?

How do I use configure.ac to include the contents of AC_INCLUDES_DEFAULT?

AC_INCLUDES_DEFAULT 是一个扩展为一堆标准头文件的宏,加上相关的 autoconf 生成的检查。事实上,文档说它扩展为:

#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
#  include <stdlib.h>
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
#  include <memory.h>
# endif
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif

如何使用 configure.acAC_INCLUDES_DEFAULT 的内容包含在我的 config.h 中?

AC_INCLUDES_DEFAULT 供 autoconf 检查宏使用。它不会输出任何你可以直接在你的项目中使用的东西。

我觉得这个列表有点过时了。似乎不太可能有任何系统提供 <strings.h> 但不再提供 <string.h>。一般来说,我认为最好检查一下你实际使用的是什么;甚至除此之外,仅适用于您在实践中发现无法移植到您关心的平台的内容。