Добавление вектора в NS2; Ошибка компилятора

Я пытался добавить # include <vector> к файлу симулятора NS2, но я сталкиваюсь с проблемами.
Я получаю эту ошибку (я использовал другой компьютер с g ++ 4.6, а не старый g ++ 4.4).
почему только в том числе <vector> вызывает ошибку?

`g++ -c -Wall -Wno-write-strings  -DTCP_DELAY_BIND_ALL -DNO_TK -DTCLCL_CLASSINSTVAR  -DNDEBUG -DLINUX_TCP_HEADER -DUSE_SHM -DHAVE_LIBTCLCL -DHAVE_TCLCL_H -DHAVE_LIBOTCL1_14 -DHAVE_OTCL_H -DHAVE_LIBTK8_5 -DHAVE_TK_H -DHAVE_LIBTCL8_5 -DHAVE_TCLINT_H -DHAVE_TCL_H  -DHAVE_CONFIG_H -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=std -DUSE_SINGLE_ADDRESS_SPACE -Drng_test  -I. -I. -I/home/ns235/ns-allinone-2.35/tclcl-1.20 -I/home/ns235/ns-allinone-2.35/otcl -I/home/ns235/ns-allinone-2.35/include -I/home/ns235/ns-allinone-2.35/include -I/home/ns235/ns-allinone-2.35/include -I/usr/include/pcap -I./tcp -I./sctp -I./common -I./link -I./queue -I./adc -I./apps -I./mac -I./mobile -I./trace -I./routing -I./tools -I./classifier -I./mcast -I./diffusion3/lib/main -I./diffusion3/lib -I./diffusion3/lib/nr -I./diffusion3/ns -I./diffusion3/filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -o tcp/tcp-fack.o tcp/tcp-fack.cc
In file included from /usr/include/c++/4.6/vector:61:0,
from tcp/tcp-fack.cc:28:
/usr/include/c++/4.6/bits/stl_algobase.h: In function ‘const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = TracedInt]:
tcp/tcp-fack.cc:87:37:   instantiated from here
/usr/include/c++/4.6/bits/stl_algobase.h:215:7: error: no match for ‘operator<’ in ‘__a  < __b’
/usr/include/c++/4.6/bits/stl_algobase.h:215:7: note: candidates are:
/usr/include/c++/4.6/bits/stl_algobase.h:215:7: note: operator<(int, int) <built-in>
/usr/include/c++/4.6/bits/stl_algobase.h:215:7: note:   no known conversion for argument 2 from ‘const TracedInt’ to ‘int’
/usr/include/c++/4.6/bits/stl_pair.h:207:5: note: template<class _T1, class _T2> bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/usr/include/c++/4.6/bits/stl_iterator.h:291:5: note: template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:341:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_IteratorL>&, const   std::reverse_iterator<_IteratorR>&)
/usr/include/c++/4.6/bits/stl_vector.h:1290:5: note: template<class _Tp, class _Alloc>   bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
make: *** [tcp/tcp-fack.o] Error 1

Вот фрагмент строки stl_algobase.h (197-218). Использует templete в tcp-fack.cc вызывая ошибку? (http://www.cs.rit.edu/usr/local/pub/swm/gcc-4.7.2/include/c++/4.7.2/bits/stl_algobase.h)

/**
*  @brief This does what you think it does.
*  @ingroup sorting_algorithms
*  @param  __a  A thing of arbitrary type.
*  @param  __b  Another thing of arbitrary type.
*  @return   The greater of the parameters.
*
*  This is the simple classic generic implementation.  It will work on
*  temporary expressions, since they are only evaluated once, unlike a
*  preprocessor macro.
*/

template<typename _Tp>
inline const _Tp&
max(const _Tp& __a, const _Tp& __b)
{
// concept requirements
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
//return  __a < __b ? __b : __a;
if (__a < __b)
return __b;
return __a;
}

ниже приведен фрагмент файла tcp-fack.cc.Вот оригинальный файл с номером строки https://github.com/hbatmit/ns2.35/blob/master/tcp/tcp-fack.cc (Я только добавил <vector> в строке 28)

#ifndef lint
static const char rcsid[] =
"@(#) /home/ctk21/cvsroot//hssstcp/ns/ns-2.1b9/tcp/tcp-fack.cc,v 1.2 2002/08/12 10:43:58     ctk21 Exp (PSC)";
#endif

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <vector>   //line 28
#include "ip.h"#include "tcp.h"#include "flags.h"#include "scoreboard.h"#include "random.h"#include "tcp-fack.h"#include "template.h"
static class FackTcpClass : public TclClass {
public:
FackTcpClass() : TclClass("Agent/TCP/Fack") {}
TclObject* create(int, const char*const*) {
return (new FackTcpAgent());
}
} class_fack;/*
* Process a dupack.
*/
void FackTcpAgent::oldack(Packet* pkt)
{
hdr_tcp *tcph = hdr_tcp::access(pkt);

last_ack_ = tcph->seqno();
highest_ack_ = last_ack_;
fack_ = max(fack_,highest_ack_);
/*
* There are conditions under which certain versions of TCP (e.g., tcp-fs)
* retract maxseq_. The following line of code helps in those cases. For
* versions of TCP, it is a NOP.
*/
maxseq_ = max(maxseq_, highest_ack_);// This is line 87
if (t_seqno_ < last_ack_ + 1)
t_seqno_ = last_ack_ + 1; // This is line 89
newtimer(pkt);
if (rtt_active_ && tcph->seqno() >= rtt_seq_) {
rtt_active_ = 0;
t_backoff_ = 1;
}
/* with timestamp option */
double tao = Scheduler::instance().clock() - tcph->ts_echo();
rtt_update(tao);
if (ts_resetRTO_) {
// From Andrei Gurtov
// FACK has not been updated to make sure the ECN works
//   correctly in this case - Sally.
t_backoff_ = 1;
}
/* update average window */
awnd_ *= 1.0 - wnd_th_;
awnd_ += wnd_th_ * cwnd_;
/* if the connection is done, call finish() */
if ((highest_ack_ >= curseq_-1) && !closed_) {
closed_ = 1;
finish();
}
}

int FackTcpAgent::maxsack(Packet *pkt)
{
hdr_tcp *tcph = hdr_tcp::access(pkt);
int maxsack=-1, sack_index;

for (sack_index=0; sack_index < tcph->sa_length(); sack_index++) {
if (tcph->sa_right(sack_index) > maxsack)
maxsack = tcph->sa_right(sack_index);
}
return (maxsack-1);
}

** Я заменил <vector> с <map> и это показало следующую ошибку **

g++ -c -Wall -Wno-write-strings  -DTCP_DELAY_BIND_ALL -DNO_TK -DTCLCL_CLASSINSTVAR  -DNDEBUG -DLINUX_TCP_HEADER -DUSE_SHM -DHAVE_LIBTCLCL -DHAVE_TCLCL_H -DHAVE_LIBOTCL1_14 -DHAVE_OTCL_H -DHAVE_LIBTK8_5 -DHAVE_TK_H -DHAVE_LIBTCL8_5 -DHAVE_TCLINT_H -DHAVE_TCL_H  -DHAVE_CONFIG_H -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=std -DUSE_SINGLE_ADDRESS_SPACE -Drng_test  -I. -I. -I/home/ns235/ns-allinone-2.35/tclcl-1.20 -I/home/ns235/ns-allinone-2.35/otcl -I/home/ns235/ns-allinone-2.35/include -I/home/ns235/ns-allinone-2.35/include -I/home/ns235/ns-allinone-2.35/include -I/usr/include/pcap -I./tcp -I./sctp -I./common -I./link -I./queue -I./adc -I./apps -I./mac -I./mobile -I./trace -I./routing -I./tools -I./classifier -I./mcast -I./diffusion3/lib/main -I./diffusion3/lib -I./diffusion3/lib/nr -I./diffusion3/ns -I./diffusion3/filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -o tcp/tcp-fack.o tcp/tcp-fack.cc
In file included from /usr/include/c++/4.6/bits/stl_tree.h:63:0,
from /usr/include/c++/4.6/map:60,
from tcp/tcp-fack.cc:28:
/usr/include/c++/4.6/bits/stl_algobase.h: In function ‘const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = TracedInt]’:
tcp/tcp-fack.cc:87:37:   instantiated from here
/usr/include/c++/4.6/bits/stl_algobase.h:215:7: error: no match for ‘operator<’ in ‘__a < __b’
/usr/include/c++/4.6/bits/stl_algobase.h:215:7: note: candidates are:
/usr/include/c++/4.6/bits/stl_algobase.h:215:7: note: operator<(int, int) <built-in>
/usr/include/c++/4.6/bits/stl_algobase.h:215:7: note:   no known conversion for argument 2 from ‘const TracedInt’ to ‘int’
/usr/include/c++/4.6/bits/stl_pair.h:207:5: note: template<class _T1, class _T2> bool  std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/usr/include/c++/4.6/bits/stl_iterator.h:291:5: note: template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:341:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
/usr/include/c++/4.6/bits/stl_tree.h:866:5: note: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator<(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
/usr/include/c++/4.6/bits/stl_map.h:899:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)
/usr/include/c++/4.6/bits/stl_multimap.h:817:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
make: *** [tcp/tcp-fack.o] Error 1

-1

Решение

Я нашел решение;
NS-2 template.h имеет функции swap () и max (). swap () является функцией-членом стандарта <vector>, и max () является функцией-членом стандарта stl_algorithm(), Также в NS-2 god.h есть класс под названием vector (). Эти функции NS-2 вызывали конфликты с <Vector> а также <algorithm> библиотеки.

Я изменил названия функций NS2 и теперь все работает.

Спасибо

0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]