• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

Problem with STL.

4 posts in this topic

hi everyone.

I'm having some strange problems with the STL in C++.


I have this code:


for(i=0; i<theTree.size(); ++i)
	{	//Look if the rule already exits
		for(j=leftSides.begin(); j!=leftSides.end(); ++j)
			if((*j).rule.type==theTree[i][0].type && strcmp((*j).rule.text, theTree[i][0].text))
		//If it exists add the lefts side
			//If it does not exists, push it and add left side



The definitions are:


std::vector<std::vector<struct token> > theTree;
std::vector<struct parts_list>leftSides;
std::set<struct token> tempSet;
struct parts_list tempList;

All this is part of a little compiler i'm implementing, but when i try to compile the code it gives me this:

g++ main.cpp cLexicParser.cpp cSyntaxParser.cpp -o grammar
cSyntaxParser.cpp: En la función miembro ‘void cSyntaxParser::PrintTree()’:
cSyntaxParser.cpp:75:46: aviso: formato ‘%d’ espera un argumento de tipo ‘int’, pero el argumento 2 es de tipo ‘std::vector<std::vector<token> >::size_type {aka long unsigned int}’ [-Wformat]
cSyntaxParser.cpp: En la función miembro ‘bool cSyntaxParser::createLeftSides()’:
cSyntaxParser.cpp:142:14: error: ‘class std::vector<parts_list>’ no tiene un miembro llamado ‘pushBack’
cSyntaxParser.cpp: En el ámbito global:
cSyntaxParser.cpp:148:42: error: no hay una función miembro ‘bool cSyntaxParser::createRightSides()’ declarada en la clase ‘cSyntaxParser’
cSyntaxParser.cpp:153:41: error: no hay una función miembro ‘void cSyntaxParser::LS(token)’ declarada en la clase ‘cSyntaxParser’
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_tree.h:65:0,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/set:60,
                 from structs.h:3,
                 from cSyntaxParser.h:1,
                 from cSyntaxParser.cpp:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_function.h: En la función miembro ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [con _Tp = token]’:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_tree.h:1277:4:   instanciado desde ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(const _Val&) [con _Key = token, _Val = token, _KeyOfValue = std::_Identity<token>, _Compare = std::less<token>, _Alloc = std::allocator<token>]’
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_set.h:410:29:   instanciado desde ‘std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename _Alloc::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [con _Key = token, _Compare = std::less<token>, _Alloc = std::allocator<token>, typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename _Alloc::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<token>, std::set<_Key, _Compare, _Alloc>::value_type = token]’
cSyntaxParser.cpp:140:32:   instanciado desde aquí
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_function.h:236:22: error: no hay coincidencia para ‘operator<’ en ‘__x < __y’
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_function.h:236:22: nota: los candidatos son:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_pair.h:207:5: nota: template<class _T1, class _T2> bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_iterator.h:291:5: nota: template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_iterator.h:341:5: nota: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_tree.h:866:5: nota: 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/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_set.h:713:5: nota: template<class _Key, class _Compare, class _Alloc> bool std::operator<(const std::set<_Key, _Compare, _Alloc>&, const std::set<_Key, _Compare, _Alloc>&)
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_multiset.h:696:5: nota: template<class _Key, class _Compare, class _Alloc> bool std::operator<(const std::multiset<_Key, _Compare, _Alloc>&, const std::multiset<_Key, _Compare, _Alloc>&)
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_vector.h:1290:5: nota: template<class _Tp, class _Alloc> bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)

which is quite chaotic.


I can't use any pair utility because it also yield this same error message.

Can someone tell me what's going on?

BTW, sorry, the compiler is in spanish, although i think it can be understood.


Share this post

Link to post
Share on other sites

I just looked at the first one. This is just a wild guess because you provide no line numbers, and some of the code is missing. But - it looks like the first error is complaining that it's expecting an int instead of a size_t. Is your i loop variable of type int? Change it to size_t.


Share this post

Link to post
Share on other sites

hi again.

Thanks for your answers.

The real problem i was having trouble with is number 4. I forgot to define the operator <.

It is hard to read the errors because, first, it looks chaotic in the terminal, second, there is a lot of text for one error(the last one).

Anyway, this was really helpful. Thanks a lot.


Share this post

Link to post
Share on other sites

Some of those warnings and errors are easy to fix, because the compiler is telling you exactly what the problem is.  So why not fix them instead of just posting all that stuff if you're only having a problem with one of them?  Yes, of course it's going to look chaotic if you're trying to solve problem 4 without first addressing problems 1 through 3.  This is basic stuff.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0