I don't understand these build issues...

This is a discussion on I don't understand these build issues... within the C++ Programming forums, part of the General Programming Boards category; I don't understand these build issues when trying to compile: from /usr/include/c++/4.6/bits/locale_classes.h:42, from /usr/include/c++/4.6/bits/ios_base.h:43, from /usr/include/c++/4.6/ios:43, from /usr/include/c++/4.6/istream:40, from /usr/include/c++/4.6/fstream:40, ...

  1. #1
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827

    Arrow I don't understand these build issues...

    I don't understand these build issues when trying to compile:

    from /usr/include/c++/4.6/bits/locale_classes.h:42,
    from /usr/include/c++/4.6/bits/ios_base.h:43,
    from /usr/include/c++/4.6/ios:43,
    from /usr/include/c++/4.6/istream:40,
    from /usr/include/c++/4.6/fstream:40,
    from C_html4_tags.cpp:2:
    /usr/include/c++/4.6/bits/stl_function.h:-1: In member function ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = S_browser]’:
    /usr/include/c++/4.6/bits/stl_function.h:236: error: no match for ‘operator<’ in ‘__x < __y’
    candidates are:
    /usr/include/c++/4.6/bits/stl_pair.h:207: 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: 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: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
    /usr/include/c++/4.6/bits/basic_string.h:2510: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
    /usr/include/c++/4.6/bits/basic_string.h:2522: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
    /usr/include/c++/4.6/bits/basic_string.h:2534: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
    /usr/include/c++/4.6/bits/stl_vector.h:1290: template<class _Tp, class _Alloc> bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
    /usr/include/c++/4.6/bits/stl_tree.h:856: 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:894: 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:812: 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>&)
    Line 2 of C_html4_tags.cpp is "#include <fstream>". Because of the "S_browser" part of the message (marked in bold), and the thing about 'operator<', I was thinking that maybe somewhere in the code I was misusing the operator '<' somewhere near 'S_browser', but I already looked through everywhere which contained references to S_browser, and did not spot any errors, or even uses of the < operator with S_browser or map<S_browser, TYPE_attr_values> or anywhere near those things. And since the build issues doesn't actually identify the line of my code which is producing these messages, I'm lost as to where to look to find the cause of the problem.

    Any thoughts on this matter?

    Thanks.
    Last edited by Programmer_P; 09-23-2012 at 08:55 AM.
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,648
    What is the relevant code?

    EDIT:
    Wait, let's try this again: simplify your code to the point where it can be no simpler yet demonstrates this error, then post that simplified code.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by laserlight View Post
    What is the relevant code?

    EDIT:
    Wait, let's try this again: simplify your code to the point where it can be no simpler yet demonstrates this error, then post that simplified code.
    I'm not sure what the relevant code is. That's why I didn't post any.
    But after reading your post, I tried commenting out different member functions of my C_html4_tags class, and verified that the problem is not connected with any of them, since its still there when the functions are commented out.
    So the only possible source could be the constructor of the class, which I'm now trying to go through again, piece by piece, commenting out different sections, until I pinpoint the location. Thanks for the idea.
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    2,552
    Wild guess on my part is the less than < defined for bool operations?

    In other words is false less than true?

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  5. #5
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by stahta01 View Post
    Wild guess on my part is the less than < defined for bool operations?

    In other words is false less than true?

    Tim S.
    Yes. But what does that have to do with it?
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    It seems to me that class S_browser itself needs to overload operator< as well.

    That is, if you're storing these things in a map, you need to be able to say whether one instance of a S_browser is "before" another.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by Salem View Post
    It seems to me that class S_browser itself needs to overload operator< as well.

    That is, if you're storing these things in a map, you need to be able to say whether one instance of a S_browser is "before" another.
    Well, yes, that might be useful if I actually wanted to compare different S_browser objects with one another, but right now I don't see a use for that.
    All the S_browser struct is for is to keep separate lists of supported attributes of each tag for each major browser, i.e. so that the ones which IE supports are stored in a different set than those of FF, and so forth.
    It also is for keeping separate the attribute values one browser supports from another. In the first case, I just use a vector<S_browser> member of S_html_attr, and in the second, I use a map<S_browser, TYPE_attr_values> member of where "TYPE_attr_values" is a type definition of a vector<S_html_attr_value>. That way, when I want to output a list of Html attributes of a tag for a given browser, I can check each attribute to see if its supported in that browser, and if it is, output it; if not, then don't. And then for each attribute, I can directly access a list of attribute values
    corresponding to the ones for that attribute which that browser supported, and present it to the user. Of course, I could have accomplished the same thing using other methods too, but this is the way I decided to do it, though I don't remember my reasoning.
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  8. #8
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,302
    Quote Originally Posted by Programmer_P View Post
    Well, yes, that might be useful if I actually wanted to compare different S_browser objects with one another, but right now I don't see a use for that.
    It makes no difference if you have a use for it or not.
    Because you have map<S_browser, TYPE_attr_values>, it is mandatory to provide it in order for the code to compile.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  9. #9
    Registered User
    Join Date
    Oct 2006
    Posts
    2,370
    since you're using gcc 4.6, you can use std::unordered_map instead of std::map. just include <unordered_map>, add compiler command line option-std=c++0x, and all should be well.

  10. #10
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by iMalc View Post
    It makes no difference if you have a use for it or not.
    Because you have map<S_browser, TYPE_attr_values>, it is mandatory to provide it in order for the code to compile.
    Hmm...it seems you're right. I added an overloaded < operator to the S_browser struct, and that got rid of the error messages above.

    However, now its giving me 3324 errors and 25 warnings about things I know is not actually true about my code, i.e. saying things like "multiple definition of 'F_getHtmlCharCode(char const&)' (and this in a header file that does not actually contain that function at all!), and "undefined reference to C_html4_attributes::blah_blah_blah" (again something that is not true, since the whole C_html4_attributes class has both compiled and run ok in a separate project from C_html4_tags, and the C_html4_attributes.h header file which contains the declarations of all the things it complains about is included in the C_html4_tags.h file, thus linking the two modules together). It basically just gave me a load of horse........ after I thought I was finally about done the class (that last error I mentioned, which now appears to be solved, was the last one it was reporting before I made the change to fix it). GRRHH!!!
    Last edited by Programmer_P; 09-24-2012 at 10:49 PM.
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  11. #11
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    > i.e. saying things like "multiple definition of 'F_getHtmlCharCode(char const&)' (and this in a header file that does not actually contain that function at all!)
    It seems likely that you've got source code in header files.

    If you've got source code in a header file, and you #include it in more that one place, then you get several copies of that code, and hence it is "multiply defined".
    FAQ > Multiple source files for one program (C++ example) - Cprogramming.com
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  12. #12
    Registered User
    Join Date
    Oct 2006
    Posts
    2,370
    Quote Originally Posted by Salem View Post
    If you've got source code in a header file, and you #include it in more that one place, then you get several copies of that code, and hence it is "multiply defined".
    the way that I resolve this issue, when having those functions in the header is unavoidable (template functions), is to declare them as inline.

  13. #13
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,648
    Quote Originally Posted by Elkvis
    the way that I resolve this issue, when having those functions in the header is unavoidable (template functions), is to declare them as inline.
    You don't need to declare the function template as inline in order to avoid breaking the one definition rule when you define a function template in a header that is included in multiple translation units.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. build GNU GCC 4.3.1
    By MarkZWEERS in forum Tech Board
    Replies: 8
    Last Post: 08-10-2008, 10:43 AM
  2. PC build...
    By Bajanine in forum Tech Board
    Replies: 20
    Last Post: 05-23-2007, 10:39 AM
  3. how to build AST ?!
    By Meshal in forum C Programming
    Replies: 7
    Last Post: 12-13-2006, 05:05 AM
  4. non dot net build
    By luigi40 in forum C# Programming
    Replies: 11
    Last Post: 11-08-2005, 03:11 PM
  5. Build my own *.lib
    By Markitos in forum C Programming
    Replies: 1
    Last Post: 10-31-2001, 04:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21