1
我正在编写一个使用boost::asio
来访问串行端口的程序。根据文档,当定义宏BOOST_ASIO_HAS_SERIAL_PORT
时串行端口支持可用。由于这是一项要求,如果宏未定义,我希望我的配置脚本中止。autoconf:如何检查#define的存在
我以为我可以像下面这样实现这一点:
AC_MSG_CHECKING([for serial port support in boost::asio])
AC_EGREP_CPP(yes_have_boost_asio_serial, [
#include <boost/asio.hpp>
#ifdef BOOST_ASIO_HAS_SERIAL_PORT
yes_have_boost_asio_serial
#endif
], [
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
AC_ERROR([boost::asio must be compiled with serial port support enabled])
])
不幸的是,当我把这个,我得到生成的配置脚本时,一个奇怪的错误:
configure.ac:23: error: possibly undefined macro: BOOST_ASIO_HAS_SERIAL_PORT
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
为什么autoconf在我的代码中看到宏?关于m4_pattern_allow
的文档或多或少地表示,如果您必须使用它,出了问题,那么我做错了什么?
适用于我,没有错误使用autoconf 2.69。 – ldav1s