Reputation: 27340
I am writing a program that uses boost::asio
to access serial ports. According to the documentation, serial port support is available when the BOOST_ASIO_HAS_SERIAL_PORT
macro is defined. Since this is a requirement, I want my configure script to abort if the macro has not been defined.
I thought I could achieve this with something like the following:
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])
])
Unfortunately when I put this in, I get a weird error when generating the configure script:
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.
Why is autoconf seeing macros inside my code? The documentation on m4_pattern_allow
more or less says if you have to use it something has gone wrong, so what have I done wrong?
Upvotes: 1
Views: 521
Reputation: 27340
I ended up just using m4_pattern_allow
, I guess it has something to do with an all-uppercase symbol looking like something autoconf should deal with?
m4_pattern_allow([BOOST_ASIO_HAS_SERIAL_PORT])
AC_MSG_CHECKING([for serial port support in boost::asio])
...
Upvotes: 2