Compilation problems on VC7 of code uses boost 1.31.0

Hi I need your example in compilation errors on code uses boost under Windows VC7 and HP-UX 11.11 aCC 3.55 in 64 bit mode. We have the boost 1.31.0 successfully installed and used in our products, in SunOS using Forte 6.5.3 CC, HP 11.11 using aCC 3.33, Windows (W2k, XP) using VC6. While porting our code to 64 bit, we have upgraded the development env` to Forte 8.5.5 CC on Sun, aCC 3.55 on HP and VC7 on Windows. Compilation of boost itself had no problem. However, compilation of our products that using it has been failed on HP and Windows. 1. Problems on Windows: We have the following piece of code that uses boost (copy/paste): #include "boost/regex.h" #include "boost/regex.hpp" using namespace boost; using namespace std; typedef boost::reg_expression<char> re_type; typedef re_type::allocator_type allocator_type; long example_func(long pos, const std::string& regE, long& reslen, long max) { long res; boost::match_results <PData::iterator, allocator_type> m; allocator_type (a); re_type e (a); e.set_expression (regE, regbase::normal); if (regex_search (begin (), end (), m, e, match_not_dot_newline | match_not_dot_null)) <-- line 4790 { res = pos + m.position(); reslen = m.length(); return res; } . . . Compiling the above produce the following error: parser.cpp z:\n2_3rd_party_components\boost\delivery\include\boost\regex\v4\perl_ma tcher_common.hpp(208) : error C2228: left of '.second' must have class/struct/union type type is 'const std::allocator<_Ty>::value_type' with [ _Ty=char ] z:\n2_3rd_party_components\boost\delivery\include\boost\regex\v4\basic_r egex.hpp(243) : while compiling class-template member function 'bool boost::re_detail::perl_matcher<BidiIterator,Allocator,traits,Allocator2> ::find_imp(void)' with [ BidiIterator=PData::iterator, Allocator=allocator_type, traits=boost::regex_traits<char>, Allocator2=std::allocator<char> ] c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xlocmon(190) : while compiling class-template member function 'boost::re_detail::perl_matcher<BidiIterator,Allocator,traits,Allocator2
::perl_matcher(BidiIterator,BidiIterator,boost::match_results<BidiItera tor,Allocator> &,const boost::reg_expression<charT> &,boost::regex_constants::match_flag_type)' with [ BidiIterator=PData::iterator, Allocator=allocator_type, traits=boost::regex_traits<char>, Allocator2=std::allocator<char>, charT=char ]
z:\n2_3rd_party_components\boost\delivery\include\boost\regex\v4\regex_s earch.hpp(38) : see reference to class template instantiation 'boost::re_detail::perl_matcher<BidiIterator,Allocator,traits,Allocator2
' being compiled with [ BidiIterator=PData::iterator, Allocator=allocator_type, traits=boost::regex_traits<char>, Allocator2=std::allocator<char> ] z:\med2\dev\ParserLib\parser.cpp(4790) : see reference to function template instantiation 'bool boost::regex_search<PData::iterator,allocator_type,char,boost::regex_tra its<charT>,std::allocator<_Ty>>(BidiIterator,BidiIterator,boost::match_r esults<BidiIterator,Allocator> &,const boost::reg_expression<charT> &,boost::regex_constants::match_flag_type)' being compiled with [ charT=char, _Ty=char, BidiIterator=PData::iterator, Allocator=allocator_type ]
"z:\med2\dev\ParserLib\parser.cpp(4790)" is marked above with red. "z:\n2_3rd_party_components\boost\delivery\include\boost\regex\v4\regex_ search.hpp(38)" is listed below: template <class BidiIterator, class Allocator, class charT, class traits, class Allocator2> bool regex_search(BidiIterator first, BidiIterator last, match_results<BidiIterator, Allocator>& m, const reg_expression<charT, traits, Allocator2>& e, match_flag_type flags = match_default) { if(e.flags() & regex_constants::failbit) return false; re_detail::perl_matcher<BidiIterator, Allocator, traits, Allocator2> matcher(first, last, m, e, flags); <-- line 38 return matcher.find(); } "z:\n2_3rd_party_components\boost\delivery\include\boost\regex\v4\perl_m atcher_common.hpp(208)" is part of the following function: template <class BidiIterator, class Allocator, class traits, class Allocator2> bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_imp() and the line (208) is listed below: // start again: search_base = position = m_result[0].second; <-- line 208 // If last match was null and match_not_null was not set then increment // our start position, otherwise we go into an infinite loop: Searching Google for this problem did not help very much, so I was wondering if you have encounter it and put more light on it and the solution? 2. Problems on HP: 2.1. Error 24: "/VOBS/netrac2_3rd_party/boost/delivery/include/boost/regex/v4/regbase.h pp", line 53 # '<identifier>' expected instead of 'collate'. perlex = collate << 1, // perl extensions ^^^^^^^ Error 164: "/VOBS/netrac2_3rd_party/boost/delivery/include/boost/regex/v4/regbase.h pp", line 53 # Integral type expected for operator '<<'; types found were '<no type>' and 'int'. perlex = collate << 1, // perl extensions ^^^^ We do not understand why the error occurs, can you help with that? from some reason, HP's aCC doesn't like the "collate". Again, same as with problem #1, google it did not produce any useful information. We have workaround this problem as follow: changed: collate = icase << 1, // use locale specific collation perlex = collate << 1, // perl extensions to: collate = icase << 1, // use locale specific collation _collate = icase << 1, perlex = _collate << 1, // perl extensions What do you think about this solution? 2.2. Fixing above problem have exposed a problem similar to the Windows problem. Btw, both problems #1 and #2.2 were solved when set #define BOOST_NO_STD_ALLOCATOR Regards, Miko Nahum

We have the following piece of code that uses boost (copy/paste):
I'm afraid I don't have a copy of 1.31 lying around anymore, but your problems are almost certainly allocator related. Can you remove the allocator related code? As it stands your code doesn't actually "do" anything. Or or you actually using a custom allocator? As for the HP aCC problem: it's very similar to one that occurs with VC7 when there's a "using namespace std;" declaration before including regex: the compiler is then unable to differentiate between std::collate (the template) and boost::collate (the constant), and it's a compiler bug. Otherwise your workaround is as good as any I guess. Are you in a position to upgrade to Boost-1.33.1 ? The bad news is that your code as it stands will likely need some porting to make the change (reg_expression has been deprecated in favour of basic_regex for example, but the typedefs like boost::regex boost::wregex etc are all the same). The good news is that the regex matching code has been substantially re-written to be much faster, and hardly does any memory allocation at all (or even none at all under ideal conditions), so custom allocators are very much a thing of the past. It would simplify your code to: #include "boost/regex.hpp" using namespace boost; using namespace std; typedef boost::regex re_type; long example_func(long pos, const std::string& regE, long& reslen, long max) { long res; boost::match_results <PData::iterator> m; re_type e; e.assign (regE, regbase::normal); if (regex_search (begin (), end (), m, e, match_not_dot_newline | match_not_dot_null)) { res = pos + m.position(); reslen = m.length(); return res; } Sorry I can't be more helpful about this: diagnosing these kinds of deep template instantiation errors are next to impossible sometimes, but are almost always errors in the template argument list. Hope this helps a little at least, John.
participants (2)
-
John Maddock
-
Miko Nahum