Home

Lange Fehlermeldung, kleine Ursache

Mittwoch, 19. Januar 2011 | Autor:

/home/nico/code/FAnToM/src/visAlgos/StreakSurface/FStreakSurfaceAlgorithm.cc: In member function ‘void FStreakSurfaceAlgorithm::DCELtest()’:
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/FStreakSurfaceAlgorithm.cc:245:43: error: no match for ‘operator<<’ in ‘std::cout << ((DCEL::HalfEdge*)((DCEL::HalfEdge*)((boost::intrusive::detail::add_const_if_c::type*)x.boost::intrusive::list_iterator::operator* [with Container = boost::intrusive::list_impl, (boost::intrusive::link_mode_type)1u, boost::intrusive::default_tag, 1>, long unsigned int, true> >, bool IsConst = false, typename boost::intrusive::detail::add_const_if_c::type& = DCEL::HalfEdge&, typename boost::intrusive::detail::add_const_if_c::type = DCEL::HalfEdge]

())->DCEL::HalfEdge::getNext())->DCEL::HalfEdge::getNext())->DCEL::HalfEdge::getNext()’
/usr/include/c++/4.5/ostream:108:7: note: candidates are: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:117:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream, std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios]
/usr/include/c++/4.5/ostream:127:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:165:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:169:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:173:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/bits/ostream.tcc:91:5: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits]
/usr/include/c++/4.5/ostream:180:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/bits/ostream.tcc:105:5: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits]
/usr/include/c++/4.5/ostream:191:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:200:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:204:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:209:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:213:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:221:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/ostream:225:7: note:                 std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream]
/usr/include/c++/4.5/bits/ostream.tcc:119:5: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf]
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../Fge/src/Fge_config.hh:234:22: note:                 std::ostream& operator<<(std::ostream&, const Fge::CameraMode&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FTimeDependentTensorField.hh:133:15: note:                 std::ostream& operator<<(std::ostream&, const FTimeDependentTensorField&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FTensorField.hh:59:22: note:                 std::ostream& operator<<(std::ostream&, const FTensorFieldInfo&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FCell.hh:655:10: note:                 std::ostream& operator<<(std::ostream&, FCell::CellType)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMBifurcation.hh:241:15: note:                 std::ostream& operator<<(std::ostream&, const FAMBifurcation::bifurcationType&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:485:15: note:                 std::ostream& operator<<(std::ostream&, const FAMSingularPoint::mainType&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:479:15: note:                 std::ostream& operator<<(std::ostream&, const FAMSingularPoint::singularityType&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:474:15: note:                 std::ostream& operator<<(std::ostream&, const FAMSingularPoint::singularityNature&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../math/src/FMatrixAbstract.hh:74:15: note:                 std::ostream& operator<<(std::ostream&, const FMatrixAbstract&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../math/src/../../common/src/FException.hh:24:15: note:                 std::ostream& operator<<(std::ostream&, const FException&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/FStreakSurfaceAlgorithm.cc:245:54: error: no match for ‘operator<<’ in ‘x.boost::intrusive::list_iterator::operator* [with Container = boost::intrusive::list_impl, (boost::intrusive::link_mode_type)1u, boost::intrusive::default_tag, 1>, long unsigned int, true> >, bool IsConst = false, typename boost::intrusive::detail::add_const_if_c::type& = DCEL::HalfEdge&, typename boost::intrusive::detail::add_const_if_c::type = DCEL::HalfEdge]() << std::endl’
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../Fge/src/Fge_config.hh:234:22: note: candidates are: std::ostream& operator<<(std::ostream&, const Fge::CameraMode&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FTimeDependentTensorField.hh:133:15: note:                 std::ostream& operator<<(std::ostream&, const FTimeDependentTensorField&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FTensorField.hh:59:22: note:                 std::ostream& operator<<(std::ostream&, const FTensorFieldInfo&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FCell.hh:655:10: note:                 std::ostream& operator<<(std::ostream&, FCell::CellType)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMBifurcation.hh:241:15: note:                 std::ostream& operator<<(std::ostream&, const FAMBifurcation::bifurcationType&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:485:15: note:                 std::ostream& operator<<(std::ostream&, const FAMSingularPoint::mainType&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:479:15: note:                 std::ostream& operator<<(std::ostream&, const FAMSingularPoint::singularityType&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:474:15: note:                 std::ostream& operator<<(std::ostream&, const FAMSingularPoint::singularityNature&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../math/src/FMatrixAbstract.hh:74:15: note:                 std::ostream& operator<<(std::ostream&, const FMatrixAbstract&)
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../math/src/../../common/src/FException.hh:24:15: note:                 std::ostream& operator<<(std::ostream&, const FException&)
make[2]: *** [visAlgos/CMakeFiles/StreakSurface.dir/StreakSurface/FStreakSurfaceAlgorithm.cc.o] Error 1
make[1]: *** [visAlgos/CMakeFiles/StreakSurface.dir/all] Error 2
make: *** [all] Error 2

Keine Panik. Wich­tig ist nur

245:43: error: no match for ‘operator<<’

Zeile 245 also. Mal schaun…

cout << (*x).getNext().getNext().getNext()==(*x) << endl;

Das Pro­blem liegt in der Prio­ri­tät, mit der der Com­pi­ler die ver­schie­de­nen Ope­ra­to­ren aus­wer­tet1. << wird näm­lich vor == aus­ge­wer­tet! Daher betrach­tet der Com­pi­ler zuerst das <<:

(*x) << endl;

was fehl­schlägt, da für den Typ, von dem x ist, kein «-Ope­ra­tor defi­niert ist. Daher auch die Fehlermeldung.

Die Lösung besteht schlicht darin, Klam­mern um den Ver­gleich zu setzen:

cout << ( (*x).getNext().getNext().getNext()==(*x) ) << endl;

Damit weiß C++, dass der Ver­gleich erst mal kom­plett aus­ge­wer­tet und erst des­sen Ergeb­nis aus­ge­ge­ben wer­den soll.

  1. Nach­le­sen kann man diese soge­nannte Ope­ra­tor Pre­ce­dence zum Bei­spiel hier http://www.cppreference.com/operator_precedence.html. In der Regel ist die Rei­hen­folge schon so gemacht, dass es intui­tiv ist. Unter ande­rem wird auch das gute alte „Punkt­rech­nung vor Strich­rech­nung!” beach­tet (siehe Pre­ce­dence 5 und 6).

Tags »

Trackback: Trackback-URL |  Feed zum Beitrag: RSS 2.0
Thema: Sezierte C++-Käfer

Diesen Beitrag kommentieren.

2 Kommentare

  1. 1
    der_Karl 

    Gnihihi, bei dem Out­put musste ich mir gerade vor­stel­len, wie unser Azubi da heu­lend zusam­men­bre­chen würde. :D

  2. 2
    Nico 

    Grr­ri­hi­hih­ha­haha. Tja… da muss man wohl durch. Oder aber:
    make | less
    (auch wenn es unpro­duk­tiv klingt ;)

Kommentar abgeben