Compile errors including boost/regex.hpp
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 When I try to compile a file that includes <boost/regex.hpp> I get the following error: # /home/me/Projects/myproject> make # /usr/bin/make all-am # make[1]: Entering directory `/home/me/Projects/myproject' # compiling main.cpp (g++) # In file included from /usr/local/include/boost/regex/regex_traits.hpp:27:0, # from /usr/local/include/boost/regex/v4/regex.hpp:39, # from /usr/local/include/boost/regex.hpp:31, # [ ... more traceback ... ] # # /usr/local/include/boost/regex/v4/regex_traits.hpp:87:1: error: macro "test" passed 2 arguments, but # takes just 1 # In file included from /usr/local/include/boost/regex/v4/regex.hpp:79:0, # from /usr/local/include/boost/regex.hpp:31, # [ ... more traceback ... ] # # /usr/local/include/boost/regex/v4/regex_format.hpp:849:1: error: macro "test" passed 2 arguments, but # takes just 1 # In file included from /usr/local/include/boost/regex/regex_traits.hpp:27:0, # from /usr/local/include/boost/regex/v4/regex.hpp:39, # from /usr/local/include/boost/regex.hpp:31, # [ ... more traceback ... ] # # /usr/local/include/boost/regex/v4/regex_traits.hpp:87:1: error: template declaration of ‘char (& # boost::re_detail::test)[2]’ # /usr/local/include/boost/regex/v4/regex_traits.hpp:87:1: error: expected unqualified-id before ‘...’ # token # /usr/local/include/boost/regex/v4/regex_traits.hpp:87:1: error: expected ‘)’ before ‘...’ token # /usr/local/include/boost/regex/v4/regex_traits.hpp:87:1: error: expected ‘)’ before ‘...’ token # /usr/local/include/boost/regex/v4/regex_traits.hpp:87:1: error: expected unqualified-id before ‘(’ # token # In file included from /usr/local/include/boost/regex/v4/regex.hpp:79:0, # from /usr/local/include/boost/regex.hpp:31, # [ ... more traceback ... ] # # /usr/local/include/boost/regex/v4/regex_format.hpp:849:1: error: template declaration of ‘char (& # boost::re_detail::test)[2]’ # /usr/local/include/boost/regex/v4/regex_format.hpp:849:1: error: expected unqualified-id before ‘...’ # token # /usr/local/include/boost/regex/v4/regex_format.hpp:849:1: error: expected ‘)’ before ‘...’ token # /usr/local/include/boost/regex/v4/regex_format.hpp:849:1: error: expected ‘)’ before ‘...’ token # /usr/local/include/boost/regex/v4/regex_format.hpp:849:1: error: expected unqualified-id before ‘(’ # token # make[1]: *** [myproject-main.o] Error 1 # make[1]: Leaving directory `/home/me/Projects/myproject' # make: *** [all] Error 2 # *** Failure: Exit code 2 *** This is how I'm compiling: # g++ -DHAVE_CONFIG_H -I. `mysql_config --include` `mysql_config --cflags` -std=c++0x -g -O2 -MT # myproject-main.o -MD -MP -MF .deps/myproject-main.Tpo -c -o myproject-main.o `test -f 'src/main.cpp' # || echo './'`src/main.cpp Basically, the compile errors trace back to when I include boost/regex.hpp: | #include <boost/regex.hpp> Any ideas why this occurs? Maybe it's because I'm not including -lbooost_regex as a compile option? I specified it as my "myproject_LDADD" macro in Makefile.am so I assume g++ knows when to use it. Thanks. Sorry for the lengthy email. -----BEGIN PGP SIGNATURE----- iQEcBAEBCgAGBQJRnN/nAAoJEOT99oqiSuRNim0H/1U+xgx+TCwOtDiGfC5FH6yR 1HwZYwTb0F/7CwldOBsPoDMfjSJmptH4a4s84PR0xDHFrhvgDkjDvzYkoWPLR7gf eSAMHzQG3kvJawvHiJNSu/eTZivVfkCE14+zoE+cVriCJicJUJg1g8hp5Cydk6D3 OM9WtOY/GCVHD8lK84UX5HMqnjeX4nPLEA7nJGd1u2+5PkHxpQMF2RO+EWnlNm0e eTUdZBlGLc/RGHMgl2uF1q3b+qCRrC/Wwn/4OtkDUn0Y3V879LbkYej06oB94zWD 9kKHAnTFOisQJDUmkHr9BiEGgJ9UNO2JCVkHlzrjVgfwKe1r6FIaZmTGNpIme0c= =Av+g -----END PGP SIGNATURE-----
# /usr/local/include/boost/regex/v4/regex_format.hpp:849:1: error: macro "test" passed 2 arguments, but # takes just 1
Any ideas why this occurs? Maybe it's because I'm not including -lbooost_regex as a compile option? I specified it as my "myproject_LDADD" macro in Makefile.am so I assume g++ knows when to use it.
Yes you need to add -lboost_regex as a *linker* option, but the error is occuring because someone has defined "test" as a macro which is a very very bad idea! Try making boost/regex.hpp the first #include. HTH, John.
I did #include <boost/regex.hpp> as the first include statement. I'm the only one writing this program. I haven't defined a macro "test" anywhere. I even grepped for 'test' and found it only used as the BASH command "test" in configure and Makefile files (automatically generated from autotools). On Wed 22 May 2013 08:53:31 AM PDT, John Maddock wrote:
# /usr/local/include/boost/regex/v4/regex_format.hpp:849:1: error: macro "test" passed 2 arguments, but # takes just 1
Any ideas why this occurs? Maybe it's because I'm not including -lbooost_regex as a compile option? I specified it as my "myproject_LDADD" macro in Makefile.am so I assume g++ knows when to use it.
Yes you need to add -lboost_regex as a *linker* option, but the error is occuring because someone has defined "test" as a macro which is a very very bad idea! Try making boost/regex.hpp the first #include.
HTH, John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I did #include <boost/regex.hpp> as the first include statement. I'm the only one writing this program. I haven't defined a macro "test" anywhere. I even grepped for 'test' and found it only used as the BASH command "test" in configure and Makefile files (automatically generated from autotools).
Well actually I'm even more perplexed, because there is absolutely no usage of a function or class named "test" in current code, nor can I find anything in SVN history. What version of Boost are you using? Can you update to the latest and try again? John.
I did...I'm using 1.53. I got the same error in 1.49. I did install from source, though so I'll try completely removing all the boost library files and install from the repository. Thanks for the help, BTW. On Wed 22 May 2013 10:12:46 AM PDT, John Maddock wrote:
I did #include <boost/regex.hpp> as the first include statement. I'm the only one writing this program. I haven't defined a macro "test" anywhere. I even grepped for 'test' and found it only used as the BASH command "test" in configure and Makefile files (automatically generated from autotools).
Well actually I'm even more perplexed, because there is absolutely no usage of a function or class named "test" in current code, nor can I find anything in SVN history. What version of Boost are you using? Can you update to the latest and try again?
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Okay, who's the smart one? I was also using mysql and so I was including my_global.h (something I heard you are supposed to include with the mysql libraries). Once I removed the culprit it compiled just fine. John Maddock:
I did #include <boost/regex.hpp> as the first include statement. I'm the only one writing this program. I haven't defined a macro "test" anywhere. I even grepped for 'test' and found it only used as the BASH command "test" in configure and Makefile files (automatically generated from autotools).
Well actually I'm even more perplexed, because there is absolutely no usage of a function or class named "test" in current code, nor can I find anything in SVN history. What version of Boost are you using? Can you update to the latest and try again?
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-----BEGIN PGP SIGNATURE----- iQEcBAEBCgAGBQJRnSYBAAoJEOT99oqiSuRNtdoIAIpb5334lrdrmRfRlgwsQ6lZ foWQlw/nQoXkFdVWxOxaeDoNfCqquhU24dquCAGQyqtDwWzerU+QVXA+OvZXqTnQ ZfizMzeZZtzeQXnQlmcLEWvwMTTxL0KBaAZrQJAvFQZDstbmrCETpTKFUpsD1L0I 5O7vUWmedG78SQWazT8zFXSRA0H5V3p7mxSQJDU00KWevdM6oMSMN12z2fOTXQoz JsTuNAg1fnMYzCh9XS8Cj1k7b2seN76K9Pmp+nmxuruuJuVNmvWQckGH4MD08eOJ iqQkq1Yxzmnyx8+tdV/XFBaMdroGOOM7Nn55Yyu+ukSv+j+/4hNFmg3cV7unnf0= =wq20 -----END PGP SIGNATURE-----
"Jordan H." <jordannh@fastmail.fm> writes:
When I try to compile a file that includes <boost/regex.hpp> I get the following error:
# /home/me/Projects/myproject> make # /usr/bin/make all-am # make[1]: Entering directory `/home/me/Projects/myproject' # compiling main.cpp (g++) # In file included from /usr/local/include/boost/regex/regex_traits.hpp:27:0, # from /usr/local/include/boost/regex/v4/regex.hpp:39, # from /usr/local/include/boost/regex.hpp:31, # [ ... more traceback ... ] # # /usr/local/include/boost/regex/v4/regex_traits.hpp:87:1: error: macro "test" passed 2 arguments, but # takes just 1
That's kind of insane. On my copy of 1_53_0, that section of boost/regex/v4/regex_traits.hpp are: 85 namespace re_detail{ 86 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !BOOST_WORKAROUND(__HP_aCC, < 60000) 87 BOOST_MPL_HAS_XXX_TRAIT_DEF(boost_extensions_tag) 88 #else 89 template<class T> 90 struct has_boost_extensions_tag 91 { 92 BOOST_STATIC_CONSTANT(bool, value = false); 93 }; 94 #endif
This is how I'm compiling:
# g++ -DHAVE_CONFIG_H -I. `mysql_config --include` `mysql_config --cflags` -std=c++0x -g -O2 -MT # myproject-main.o -MD -MP -MF .deps/myproject-main.Tpo -c -o myproject-main.o `test -f 'src/main.cpp' # || echo './'`src/main.cpp
That's hard to read. Is this the same command? g++ -DHAVE_CONFIG_H -I. \ `mysql_config --include` `mysql_config --cflags` \ -std=c++0x -g -O2 \ -MT myproject-main.o -MD -MP -MF .deps/myproject-main.Tpo \ -c -o myproject-main.o \ `test -f 'src/main.cpp' || echo './'`src/main.cpp If so, you should look at the preprocessed output (although you'll likely still get warnings). You can also get the list of where all the macros are defined. Something like this: g++ -DHAVE_CONFIG_H -I. \ `mysql_config --include` `mysql_config --cflags` \ -std=c++0x -g -O2 \ -MT myproject-main.o -MD -MP -MF .deps/myproject-main.Tpo \ -dD -E -o myproject-main.i \ `test -f 'src/main.cpp' || echo './'`src/main.cpp (Note changes: "-c" to "-dD -E", and ".o" to ".i" output). Now you can look through "myproject-main.i" and see if some header is defining "test" or not. If that didn't work, a few more questions: 1. What OS and compiler, and what versions of each? 2. Is this a proper install of boost (through bootstrap etc), or did you just copy the header files in? 3. Can you get a small, self-contained example to compile successfully? (e.g., no libtool noise) Good luck! Best regards, Anthony Foiani
participants (3)
-
Anthony Foiani
-
John Maddock
-
Jordan H.