[MultiIndex] VC8: spurious compiler error

Hi! I am out of ideas here, but somebody probably fell into that trap before. Since the error message points to unrelated code, I hope to get some idea via Boost: boost_1_33_1\boost/multi_index/ordered_index.hpp(445) : error C2143: syntax error : missing ',' before '.' Since I had VC8 messing things up before I bet it is the #include order again, but I could not find the offending header yet. Markus

It could be the way you are trying to pass parameters. Can you post a snippet of what you are trying to do? Parag On 11/23/06, Markus Werle <numerical.simulation@web.de> wrote:
Hi!
I am out of ideas here, but somebody probably fell into that trap before. Since the error message points to unrelated code, I hope to get some idea via Boost:
boost_1_33_1\boost/multi_index/ordered_index.hpp(445) : error C2143: syntax error : missing ',' before '.'
Since I had VC8 messing things up before I bet it is the #include order again, but I could not find the offending header yet.
Markus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- "Civilization is the limitless multiplication of unnecessary necessities." -- Mark Twain

Parag Gadkari <parag.gadkari <at> gmail.com> writes:
It could be the way you are trying to pass parameters. Can you post a snippet
of what you are trying to do? Well, I tried to obtain something smaller, but I failed. Due to copyright restrictions I post only excerpts to give you an idea. Most of the code passed gcc-4.0.3 (cygwin), so I blame the compiler until proven wrong (looking forward to Service Pack 1). #include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/sequenced_index.hpp> #include <boost/multi_index/key_extractors.hpp> [...] #include <string> #include <iostream> [...] struct int_string_pair { int i_; std::string s_; int_string_pair(int i, std::string const & s) : i_(i) , s_(s) {} }; struct as_int {}; struct as_string {}; // shortcut for typedef struct property_storage { typedef int_string_pair value_type; typedef boost::multi_index::multi_index_container< value_type, boost::multi_index::indexed_by <boost::multi_index::sequenced<>, boost::multi_index:: ordered_unique<boost::multi_index::tag<as_int>, boost::multi_index::member<value_type, int, &value_type::i_> >, boost::multi_index:: ordered_unique<boost::multi_index::tag<as_string>, boost::multi_index::member<value_type, std::string, &value_type::s_> > > > value_storage_t; }; template <typename T> class CConfigurationProperty { public: typedef property_storage::value_type value_type; typedef property_storage::value_storage_t value_storage_t; private: value_type m_Value; value_type GetCheckedValue(int i) { value_storage_t const & possible_values = T::PossibleValues(); value_storage_t::index_iterator<as_int>::type it = boost::multi_index::get<as_int>(possible_values).find(i); ENFORCE(it != boost::multi_index::get<as_int>(possible_values).end()) ("Trying to assign invalid value '")(i) ("' to configuration property."); return value_type(*it); } value_type GetCheckedValue(std::string const & s) { value_storage_t const & possible_values = T::PossibleValues(); value_storage_t::index_iterator<as_string>::type it = boost::multi_index::get<as_string>(possible_values).find(s); ENFORCE(it != boost::multi_index::get<as_string>(possible_values).end()) ("Trying to assign invalid value '")(s) ("' to configuration property."); return value_type(*it); } public: CConfigurationProperty() : m_Value(GetCheckedValue(T::DefaultValue())) {} CConfigurationProperty(int i) : m_Value(GetCheckedValue(i)) {} CConfigurationProperty(std::string const & s) : m_Value(GetCheckedValue(s)) {} CConfigurationProperty(char const * s) : m_Value(GetCheckedValue(std::string(s))) {} operator int() const { return m_Value.i_; } operator std::string() const { return m_Value.s_; } CConfigurationProperty<T> & operator=(int i) { m_Value = GetCheckedValue(i); return *this; } CConfigurationProperty<T> & operator=(std::string const & s) { m_Value = GetCheckedValue(s); return *this; } CConfigurationProperty<T> & operator=(char const * s) { m_Value = GetCheckedValue(std::string(s)); return *this; } }; [...] struct example_type : public property_storage { static value_storage_t const & PossibleValues() { static value_storage_t const possible_values = boost::assign::list_of<int_string_pair> (-1, "undefined") (0, "foo") (1, "bar"); return possible_values; } static int DefaultValue() { return -1; } }; typedef CConfigurationProperty<example_type> example_type_t; example_type_t test; test = "foo"; assert(test != "bar"); assert(test == 0);

Markus Werle <numerical.simulation <at> web.de> writes:
Hi!
I am out of ideas here, but somebody probably fell into that trap before. Since the error message points to unrelated code, I hope to get some idea via Boost:
boost_1_33_1\boost/multi_index/ordered_index.hpp(445) : error C2143: syntax error : missing ',' before '.'
Since I had VC8 messing things up before I bet it is the #include order again, but I could not find the offending header yet.
Markus
Hello Markus, My hunch is that this is indeed just a compiler quirk, specially since you've reported that the problem is not reproducible in GCC. You can try the following: 1. What Boost version are you using? Line 445 of ordered_index.hpp in Boost 1.33.1 does not even contain a '.' character. You might try downloading a snapshot of RC_1_34_0: http://www.meta-comm.com/engineering/boost/snapshot/boost-RC_1_34_0.tar.bz2 and see if VC 8.0 is happier with that. 2. Play with precompiled header options, increase the memory available to the compiler with /Zm, switch from /ZI to a less demanding type of debugging info, disable /Gm. All these options have been proved to be beneficial in VC 6.0, maybe you're lucky in VC 8.0 as well. 3. Try using type hiding to reduce the lengths of symbols produced by multi_index containers definitions: http://boost.org/libs/multi_index/doc/compiler_specifics.html#type_hiding 4. Tag usage increase the level of stress the compiler is put under. Try elminating them in the definition of value_storage_t and acess indices by ordinal instead. You can retain some of the mnemonic nature of tags with enums: enum{ as_int=1, as_string=2 }; Please keep me informed of your progress with this. Good luck, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín M López Munoz <joaquin <at> tid.es> writes:
My hunch is that this is indeed just a compiler quirk, specially since you've reported that the problem is not reproducible in GCC. You can try the following:
1. What Boost version are you using?
1.33.1
Line 445 of ordered_index.hpp in Boost 1.33.1 does not even contain a '.' character.
Yes I know ... - wait - BINGO! If someone else states what I already know it always helps. This was the hint I needed. Someone had defined MACRO "upper" and "lower" in a header I included before multiindex stuff (only with VC8, which explains why the error did not crop up with gcc). What a pity. So it is not the compiler to blame this time, though emitting the _preprocessed_ offending line would have helped a lot in this situation. Thanks a lot! Markus
participants (3)
-
Joaquín M López Munoz
-
Markus Werle
-
Parag Gadkari