User:Stefano CiscoSystems/Compiling Issues with Vista and MSVS2008
It sounds like nobody on SLDev was interested in the problem, so I will just post here that reverting to VS2005 simply solves the problem. It is an issue with the compiles in MSVS 9, which might be worth raising to MS at some point, if only i knew how to do that. In the meanwhile, just forget using Orcas Beta 2.
could not deduce template argument from 'LLMessageThrottleEntry' in llmessagethrottle.cpp
- [VS9PATH]\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::deque<_Ty,_Alloc> &' from 'LLMessageThrottleEntry'
- [VS9PATH]\vc\include\deque(1341) : see declaration of 'std::operator =='
- [VS9PATH]\vc\include\algorithm(435) : see reference to function template instantiation '_FwdIt1 std::_Search_n<_FwdIt1,_Diff2,_Ty,bool(__cdecl *)(LLMessageThrottleEntry,LLMessageThrottleEntry)>(_FwdIt1,_FwdIt1,_Diff2,const _Ty &,_Pr,std::random_access_iterator_tag)' being compiled
The first error is related to the search_n for the LLMessageThrottleEntry class on line 113 of \indra\llmessage\llmessagethrottle.cpp.
The error happens in [yourpath]\Visual Studio 9.0\vc\include\algorithm, on line 406 (excerpt follows)
template<class _FwdIt1, class _Diff2, class _Ty, class _Pr> inline _FwdIt1 _Search_n(_FwdIt1 _First1, _FwdIt1 _Last1, _Diff2 _Count, const _Ty& _Val, _Pr _Pred, random_access_iterator_tag) { // find first _Count * _Val satisfying _Pred, random-access iterators _DEBUG_RANGE(_First1, _Last1); _DEBUG_POINTER(_Pred); if (_Count <= 0) return (_First1); _FwdIt1 _Oldfirst1 = _First1; for (; _Count <= _Last1 - _Oldfirst1; ) { // enough room, look for a match if (_Pred(*_First1, _Val)) { // found part of possible match, check it out _Diff2 _Count1 = _Count; _FwdIt1 _Mid1 = _First1; 406: for (; _Oldfirst1 != _First1 && _First1[-1] == _Val; --_First1) --_Count1; // back up over any skipped prefix if (_Count1 <= _Last1 - _Mid1) for (; ; ) // enough left, test suffix if (--_Count1 == 0) return (_First1); // found rest of match, report it else if (!_Pred(*++_Mid1, _Val)) break; // short match not at end _Oldfirst1 = ++_Mid1; // failed match, take small jump _First1 = _Oldfirst1; } else { // no match, take big jump and back up as needed _Oldfirst1 = _First1 + 1; _First1 += _Count; } } return (_Last1); }
So the problem seems to be the operator == in the equality:
_First1[-1] == _Val;
coming from the search_n operation.
They both evaluate to a
const std::deque<_Ty,_Alloc> &
which types are ambiguous for the compiler.
Here is the exact copy of the full compilation error:
1>------ Build started: Project: llmessage, Configuration: Debug Win32 ------ 1>Compiling... 1>llmessagethrottle.cpp 1>c:\sources\secondlife\lindenlabclient\indra\llmessage\llmessagethrottle.cpp(134) : warning C4189: 'message_list' : local variable is initialized but not referenced 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::deque<_Ty,_Alloc> &,const std::deque<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::deque<_Ty,_Alloc> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\deque(1341) : see declaration of 'std::operator ==' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(435) : see reference to function template instantiation '_FwdIt1 std::_Search_n<_FwdIt1,_Diff2,_Ty,bool(__cdecl *)(LLMessageThrottleEntry,LLMessageThrottleEntry)>(_FwdIt1,_FwdIt1,_Diff2,const _Ty &,_Pr,std::random_access_iterator_tag)' being compiled 1> with 1> [ 1> _FwdIt1=LLMessageThrottle::message_list_iterator_t, 1> _Diff2=int, 1> _Ty=LLMessageThrottleEntry, 1> _Pr=bool (__cdecl *)(LLMessageThrottleEntry,LLMessageThrottleEntry) 1> ] 1> c:\sources\secondlife\lindenlabclient\indra\llmessage\llmessagethrottle.cpp(117) : see reference to function template instantiation '_FwdIt1 std::search_n<LLMessageThrottle::message_list_iterator_t,int,LLMessageThrottleEntry,bool(__cdecl *)(LLMessageThrottleEntry,LLMessageThrottleEntry)>(_FwdIt1,_FwdIt1,_Diff2,const _Ty &,_Pr)' being compiled 1> with 1> [ 1> _FwdIt1=LLMessageThrottle::message_list_iterator_t, 1> _Diff2=int, 1> _Ty=LLMessageThrottleEntry, 1> _Pr=bool (__cdecl *)(LLMessageThrottleEntry,LLMessageThrottleEntry) 1> ] 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\list(1299) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\xtree(1459) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\string(90) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const _Elem *' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\string(80) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\string(70) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\vector(1309) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &,const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &)' : could not deduce template argument for 'const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\iterator(266) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\streambuf(548) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\xmemory(173) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\xutility(2193) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\xutility(2007) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'LLMessageThrottleEntry' 1> c:\program files\development\microsoft visual studio 9.0\vc\include\utility(68) : see declaration of 'std::operator ==' 1>c:\program files\development\microsoft visual studio 9.0\vc\include\algorithm(406) : error C2676: binary '==' : 'LLMessageThrottleEntry' does not define this operator or a conversion to a type acceptable to the predefined operator 1>Build log was saved at "file://c:\Sources\SecondLife\LindenLabClient\indra\llmessage\Debug\BuildLog.htm" 1>llmessage - 14 error(s), 1 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
And this is the content of the file llmessagethrottle.cpp that i am using:
/** * @file llmessagethrottle.cpp * @brief LLMessageThrottle class used for throttling messages. * * Copyright (c) 2004-2007, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab * to you under the terms of the GNU General Public License, version 2.0 * ("GPL"), unless you have obtained a separate licensing agreement * ("Other License"), formally executed by you and Linden Lab. Terms of * the GPL can be found in doc/GPL-license.txt in this distribution, or * online at http://secondlife.com/developers/opensource/gplv2 * * There are special exceptions to the terms and conditions of the GPL as * it is applied to this Source Code. View the full text of the exception * in the file doc/FLOSS-exception.txt in this software distribution, or * online at http://secondlife.com/developers/opensource/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, * and agree to abide by those obligations. * * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, * COMPLETENESS OR PERFORMANCE. */ #include "linden_common.h" #include "llhash.h" #include "llmessagethrottle.h" #include "llframetimer.h" // This is used for the stl search_n function. bool eq_message_throttle_entry(LLMessageThrottleEntry a, LLMessageThrottleEntry b) { return a.getHash() == b.getHash(); } const U64 SEC_TO_USEC = 1000000; // How long (in microseconds) each type of message stays in its throttle list. const U64 MAX_MESSAGE_AGE[MTC_EOF] = { 10 * SEC_TO_USEC, // MTC_VIEWER_ALERT 10 * SEC_TO_USEC // MTC_AGENT_ALERT }; LLMessageThrottle::LLMessageThrottle() { } LLMessageThrottle::~LLMessageThrottle() { } void LLMessageThrottle::pruneEntries() { // Go through each message category, and prune entries older than max age. S32 cat; for (cat = 0; cat < MTC_EOF; cat++) { message_list_t* message_list = &(mMessageList[cat]); // Use a reverse iterator, since entries on the back will be the oldest. message_list_reverse_iterator_t r_iterator = message_list->rbegin(); message_list_reverse_iterator_t r_last = message_list->rend(); // Look for the first entry younger than the maximum age. F32 max_age = (F32)MAX_MESSAGE_AGE[cat]; BOOL found = FALSE; while (r_iterator != r_last && !found) { if ( LLFrameTimer::getTotalTime() - (*r_iterator).getEntryTime() < max_age ) { // We found a young enough entry. found = TRUE; // Did we find at least one entry to remove? if (r_iterator != message_list->rbegin()) { // Yes, remove it. message_list->erase(r_iterator.base(), message_list->end()); } } else { r_iterator++; } } // If we didn't find any entries young enough to keep, remove them all. if (!found) { message_list->clear(); } } } BOOL LLMessageThrottle::addViewerAlert(const LLUUID& to, const char* mesg) { message_list_t* message_list = &(mMessageList[MTC_VIEWER_ALERT]); // Concatenate from,to,mesg into one string. std::ostringstream full_mesg; full_mesg << to << mesg; // Create an entry for this message. size_t hash = llhash<const char*> (full_mesg.str().c_str()); LLMessageThrottleEntry entry(hash, LLFrameTimer::getTotalTime()); // Check if this message is already in the list. /* * Stefano: i did try using this but did not help: <message_list_iterator_t,int,LLMessageThrottleEntry,bool (__cdecl *)(LLMessageThrottleEntry,LLMessageThrottleEntry)> */ message_list_iterator_t found = std::search_n(message_list->begin(), message_list->end(), 1, entry, eq_message_throttle_entry); if (found == message_list->end()) { // This message was not found. Add it to the list. message_list->push_front(entry); return TRUE; } else { // This message was already in the list. return FALSE; } } BOOL LLMessageThrottle::addAgentAlert(const LLUUID& agent, const LLUUID& task, const char* mesg) { message_list_t* message_list = &(mMessageList[MTC_AGENT_ALERT]); // Concatenate from,to,mesg into one string. std::ostringstream full_mesg; full_mesg << agent << task << mesg; // Create an entry for this message. size_t hash = llhash<const char*> (full_mesg.str().c_str()); LLMessageThrottleEntry entry(hash, LLFrameTimer::getTotalTime()); // Check if this message is already in the list. /* stefano i commented the following so to get one only error while debugging */ /* message_list_iterator_t found = std::search_n(message_list->begin(), message_list->end(), 1, entry, eq_message_throttle_entry); if (found == message_list->end()) { // This message was not found. Add it to the list. message_list->push_front(entry); return TRUE; } else { // This message was already in the list. return FALSE; } */ }