1

我正在编写一个boost::asio用于访问串行端口的程序。根据文档,BOOST_ASIO_HAS_SERIAL_PORT定义宏时可以使用串行端口支持。由于这是一项要求,因此如果尚未定义宏,我希望我的配置脚本中止。

我认为我可以通过以下方式实现这一目标:

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说,如果您必须使用它,就会出现问题,那么我做错了什么?

4

1 回答 1

2

我最终只使用了m4_pattern_allow,我想它与看起来像 autoconf 应该处理的全大写符号有关?

m4_pattern_allow([BOOST_ASIO_HAS_SERIAL_PORT])

AC_MSG_CHECKING([for serial port support in boost::asio])
...
于 2013-08-24T23:51:50.433 回答