I am trying to experiment <algorithm>'s find to search for an item in a
vector of struct. My bit of test code is shown below.
Code:
#include <algorithm>
#include <iterator>
#include <functional>
bool operator==( const ClsInstBk& rhs, const ClsInstBk& lhs );
class ClsInstBkTable
{
public:
ClsInstBkTable();
UINT32 Add( const ClsInstBk& breakpoint ); // Add a breakpoint
UINT32 Remove( const ClsInstBk& breakpoint ); // Remove a breakpoint
bool IsBreak( UINT32 ulPC ); //check if the specified PC is breakpoint or not
UINT32 ClearAll(); //clear all breakpoints
bool IsBreakInstruction( TypMemoryData ulValue );
int Find( UINT32 ulPC );//return -1 if ulPC is not set breakpoint, else return index of pool
TypMemoryData GetOriginalMemoryValue( int index );
UINT32 EnableBreak( UINT32 index );
int DisableBreak( UINT32 index );
static TypMemoryData BreakInstruction;
private:
vector<ClsInstBk> _vecBkTable;
};
......
UINT32 ClsInstBkTable::Add( const ClsInstBk& temp )
{
//if breakpoint is not in table, add it;
//std::vector<ClsInstBk>::iterator i = std::find( _vecBkTable.begin(), _vecBkTable.end(), temp );
std::vector<ClsInstBk>::iterator i;
i = std::find( _vecBkTable.begin(), _vecBkTable.end(), temp );
if( _vecBkTable.end() == i )
{
_vecBkTable.push_back( temp );
}
return 0;
}
The compile is ok. But the link is fail and errors as following.
Code:
g++ -g -Wno-deprecated -DGEN_MIF -DNO_DPI -I/localhome/tools/systemc-2.2.0/include -I/home/tools/NC_Verilog/IUS6.2/linux/tools/include/ -I. -I./../../include ./breakpoint.o ./eDSP_decode_grab.o ./eDSP_decode.o ./eDSP_cmd.o ./eDSP_disasmoneinst.o ./eDSP_grab.o ./eDSP_hardware.o ./eDSP_misc.o ./main.o -L/localhome/tools/systemc-2.2.0/lib-linux -L/usr/lib -lm -lsystemc -lpthread -o eDSP
./breakpoint.o(.gnu.linkonce.t._ZSt4findIN9__gnu_cxx17__normal_iteratorIP9ClsInstBkSt6vectorIS2_SaIS2_EEEES2_ET_S8_S8_RKT0_St26random_access_iterator_tag+0x3d): In function `__gnu_cxx::__normal_iterator<ClsInstBk*, std::vector<ClsInstBk, std::allocator<ClsInstBk> > > std::find<__gnu_cxx::__normal_iterator<ClsInstBk*, std::vector<ClsInstBk, std::allocator<ClsInstBk> > >, ClsInstBk>(__gnu_cxx::__normal_iterator<ClsInstBk*, std::vector<ClsInstBk, std::allocator<ClsInstBk> > >, __gnu_cxx::__normal_iterator<ClsInstBk*, std::vector<ClsInstBk, std::allocator<ClsInstBk> > >, ClsInstBk const&, std::random_access_iterator_tag)':
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algo.h:207: undefined reference to `operator==(ClsInstBk const&, ClsInstBk const&)'
./breakpoint.o(.gnu.linkonce.t._ZSt4findIN9__gnu_cxx17__normal_iteratorIP9ClsInstBkSt6vectorIS2_SaIS2_EEEES2_ET_S8_S8_RKT0_St26random_access_iterator_tag+0x78):/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algo.h:211: undefined reference to `operator==(ClsInstBk const&, ClsInstBk const&)'
./breakpoint.o(.gnu.linkonce.t._ZSt4findIN9__gnu_cxx17__normal_iteratorIP9ClsInstBkSt6vectorIS2_SaIS2_EEEES2_ET_S8_S8_RKT0_St26random_access_iterator_tag+0xb3):/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algo.h:215: undefined reference to `operator==(ClsInstBk const&, ClsInstBk const&)'
./breakpoint.o(.gnu.linkonce.t._ZSt4findIN9__gnu_cxx17__normal_iteratorIP9ClsInstBkSt6vectorIS2_SaIS2_EEEES2_ET_S8_S8_RKT0_St26random_access_iterator_tag+0xee):/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algo.h:219: undefined reference to `operator==(ClsInstBk const&, ClsInstBk const&)'
./breakpoint.o(.gnu.linkonce.t._ZSt4findIN9__gnu_cxx17__normal_iteratorIP9ClsInstBkSt6vectorIS2_SaIS2_EEEES2_ET_S8_S8_RKT0_St26random_access_iterator_tag+0x16f):/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algo.h:227: undefined reference to `operator==(ClsInstBk const&, ClsInstBk const&)'
./breakpoint.o(.gnu.linkonce.t._ZSt4findIN9__gnu_cxx17__normal_iteratorIP9ClsInstBkSt6vectorIS2_SaIS2_EEEES2_ET_S8_S8_RKT0_St26random_access_iterator_tag+0x1aa):/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_algo.h:231: more undefined references to `operator==(ClsInstBk const&, ClsInstBk const&)' follow
collect2: ld returned 1 exit status
I don't fully understand what the error message is trying to say.
Any comments appreciated.