[boost::wave] Finding out if a macro is defined

Hello All, using boost::wave (with context initialized as explained in the docs example) and trying to find out if some certain macro is defined leads to 2 errors: 1. Doc for context state: bool is_defined_macro(std::string const &name) const; But the source has no such function definition. I assume the signature was changed to: template <typename IteratorT2> bool is_defined_macro(IteratorT2 const &begin, IteratorT2 const &end) { return macros.is_defined(begin, end); } Trying to fix it and using the std::string::begin() and std::string::end() members to specify the begin and end range result in the error: c:\boost\include\boost-1_33_1\boost\wave\util\cpp_macromap.hpp(331) : error C2228: left of '.get_value' must have class/struct/union type is 'char' c:\boost\include\boost-1_33_1\boost\wave\cpp_context.hpp(150) : see reference to function template instantiation 'bool boost::wave::util::macromap<ContextT>::is_defined<IteratorT2>(const IteratorT &,const IteratorT &)' being compiled with [ ContextT=boost::wave::context<token_groups::str_iter_type,token_groups::lex_iter_type>, IteratorT2=char *, IteratorT=char * ] e:\projects\inpecting_wave\inpecting_wave\header_processor.cpp(177) : see reference to function template instantiation 'bool boost::wave::context<IteratorT,LexIteratorT>::is_defined_macro<char*>(const IteratorT2 &,const IteratorT2 &)' being compiled with [ IteratorT=token_groups::str_iter_type, LexIteratorT=token_groups::lex_iter_type, IteratorT2=char * ] This happens in cpp_macromap.hpp line 331: function source: template <typename ContextT> template <typename IteratorT> inline bool macromap<ContextT>::is_defined(IteratorT const &begin, IteratorT const &end) { // in normal mode the name under inspection should consist of an identifier // only token_id id = token_id(*begin); if (T_IDENTIFIER != id && !IS_CATEGORY(id, KeywordTokenType) && !IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType)) { BOOST_WAVE_THROW(preprocess_exception, invalid_macroname, impl::get_full_name(begin, end).c_str(), main_pos); } IteratorT it = begin; error line >>>>>> string_type name ((*it).get_value()); <<<<<< error line typename defined_macros_type::iterator cit(current_macros -> find(name)); if (++it != end) { // there should be only one token as the inspected name BOOST_WAVE_THROW(preprocess_exception, invalid_macroname, impl::get_full_name(begin, end).c_str(), main_pos); } return cit != current_macros -> end(); } I assume compiler dereferences iterator to char and char has no member to get_value. Does anyone have suggestions? With Kind Regards, Ovanes Markarian

Ovanes Markarian wrote:
using boost::wave (with context initialized as explained in the docs example) and trying to find out if some certain macro is defined leads to 2 errors: 1. Doc for context state: bool is_defined_macro(std::string const &name) const;
But the source has no such function definition. I assume the signature was changed to: template <typename IteratorT2> bool is_defined_macro(IteratorT2 const &begin, IteratorT2 const &end) { return macros.is_defined(begin, end); }
This is an oversight on my part. There was a function planned as described in the docs, but somehow got lost in the vault... I added it into the CVS::HEAD already.
Trying to fix it and using the std::string::begin() and std::string::end() members to specify the begin and end range result in the error:
You did the right thing here. [snipped the error explanation]
I assume compiler dereferences iterator to char and char has no member to get_value. Does anyone have suggestions?
That's a bug. It's fixed in CVS::HEAD now. You can work around this problem for now by using a instance of context_type::token_type::string_type instead of a std::string for now. I'll try to add these fixes to the upcoming release as well, but will have to ask the release manager first. Regards Hartmut
With Kind Regards,
Ovanes Markarian _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Many thanks for such a quick response! On Tue, March 6, 2007 20:09, Hartmut Kaiser wrote:
Ovanes Markarian wrote:
[snipped clarified text]
I assume compiler dereferences iterator to char and char has no member to get_value. Does anyone have suggestions?
That's a bug. It's fixed in CVS::HEAD now. You can work around this problem for now by using a instance of context_type::token_type::string_type instead of a std::string for now.
I tried to work with context_type::token_type::string_type (On my machine it is resolved to flex_string) the problem is that the construct: std::string s1("some string..."); context_type::token_type::string_type s2(s1->begin(), s1->end()); crashed the app in the assign function call from the ctor: template <class InputIterator> flex_string(InputIterator begin, InputIterator end, const A& a = A()) : Storage(a) { flex_string.hpp:1479: assign(begin, end); >>>> boom!!! } The problem is: assign calls replace: template<class InputIterator> line 1906: flex_string& replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2) { return ReplaceImpl(i1, i2, j1, j2, Selector<std::numeric_limits<InputIterator>::is_specialized>()); } Replace has BOOST_ASSERT(false) statement: template<class InputIterator> line 1897: flex_string& ReplaceImpl(iterator i1, iterator i2, InputIterator b, InputIterator e, Selector<0>) { BOOST_ASSERT(false); return *this; }
I'll try to add these fixes to the upcoming release as well, but will have to ask the release manager first.
Regards Hartmut
May be you can take a look at the calling logic and why this assertion should fail? Many Thanks for your help! With Kind Regards, Ovanes Markarian

Ovanes,
I tried to work with context_type::token_type::string_type (On my machine it is resolved to flex_string) the problem is that the construct:
std::string s1("some string..."); context_type::token_type::string_type s2(s1->begin(), s1->end());
Just use: context_type::token_type::string_type s1("some_macro_name"); if (ctx.is_macro_defined(s1.begin(), s1.end())) ... directly. I'll look into the other issue asap. Regards Hartmut
crashed the app in the assign function call from the ctor:
template <class InputIterator> flex_string(InputIterator begin, InputIterator end, const A& a = A()) : Storage(a) { flex_string.hpp:1479: assign(begin, end); >>>> boom!!! }
The problem is:
assign calls replace:
template<class InputIterator> line 1906: flex_string& replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2) { return ReplaceImpl(i1, i2, j1, j2,
Selector<std::numeric_limits<InputIterator>::is_specialized>()); }
Replace has BOOST_ASSERT(false) statement: template<class InputIterator> line 1897: flex_string& ReplaceImpl(iterator i1, iterator i2, InputIterator b, InputIterator e, Selector<0>) { BOOST_ASSERT(false); return *this; }
I'll try to add these fixes to the upcoming release as well, but will have to ask the release manager first.
Regards Hartmut
May be you can take a look at the calling logic and why this assertion should fail?
Many Thanks for your help!
With Kind Regards,
Ovanes Markarian
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

[snipped clarified text] I have one more question on this issue: 1. Can I get only wave from the head revision or do I have to install the entire release candidate? 2. How are theses changes depend on the upcoming release or head revision? 3. I assume I have to recompile the wave lib after I have taken them. Another problem which I face is taking annonymously files from the cvs. I am behind a firewall and can not login using pserver. As I understand I need to use the SSH to pass firewall, but then I am forced to have a developer key. Is it correct? If not, can someone point me to info how to take boost files from behind the firewall. Many thanks, Ovanes.

Ovanes,
I have one more question on this issue: 1. Can I get only wave from the head revision or do I have to install the entire release candidate?
Wave in the head revision is different from the Wave library in the release candidate. Both should work if separated from their resp. release. It should be sufficient to have Boost 1.33.1 to make Wave compile, I never tested this, though. The differences are documented in the Changelog file in the head revision: http://tinyurl.com/ypsluf.
2. How are theses changes depend on the upcoming release or head revision?
As I said, both versions should compile with Boost Version >= 1.33.1.
3. I assume I have to recompile the wave lib after I have taken them.
Yes, this is necessary. Regards Hartmut

Ovanes, In fact the problems will be fixed in the upcoming 1.34 release as well. I just commited the changes there as well. Regards Hartmut
Ovanes Markarian wrote:
using boost::wave (with context initialized as explained in the docs example) and trying to find out if some certain macro is defined leads to 2 errors: 1. Doc for context state: bool is_defined_macro(std::string const &name) const;
But the source has no such function definition. I assume the signature was changed to: template <typename IteratorT2> bool is_defined_macro(IteratorT2 const &begin, IteratorT2 const &end) { return macros.is_defined(begin, end); }
This is an oversight on my part. There was a function planned as described in the docs, but somehow got lost in the vault... I added it into the CVS::HEAD already.
Trying to fix it and using the std::string::begin() and std::string::end() members to specify the begin and end range result in the error:
You did the right thing here.
[snipped the error explanation]
I assume compiler dereferences iterator to char and char has no member to get_value. Does anyone have suggestions?
That's a bug. It's fixed in CVS::HEAD now. You can work around this problem for now by using a instance of context_type::token_type::string_type instead of a std::string for now.
I'll try to add these fixes to the upcoming release as well, but will have to ask the release manager first.
Regards Hartmut
With Kind Regards,
Ovanes Markarian _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Hartmut Kaiser
-
Ovanes Markarian