2013-05-18 25 views
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的文档或多或少地表示,如果您必须使用它,出了问题,那么我做错了什么?

+0

适用于我,没有错误使用autoconf 2.69。 – ldav1s

回答

2

我结束了刚刚使用m4_pattern_allow,我想这与全尺寸的大写符号看起来像autoconf应该处理的东西有关?

m4_pattern_allow([BOOST_ASIO_HAS_SERIAL_PORT]) 

AC_MSG_CHECKING([for serial port support in boost::asio]) 
...