• 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
Chad Smith

Errors on School Compiler

5 posts in this topic

EDIT: This has been fixed.  I instead just created a stringstream buffer and filled out the strings that way instead of doing it on one line.  Guess I should had known that their compiler doesn't support this yet...

 

Yes this is a school assignment that I was going to go ahead and try to compile on the schools compilers just to make sure all the test cases and everything were met before I started to clean the code up for the final submission.  Though it fails compiling on the schools submission compiler pretty bad.  

 

This was compiled with Visual Studio 2012 and it compilers perfectly with absolutely zero warnings.  When using the schools submission compiler (was never told what compiler it is using) it had brought up errors like the following:

 

Main.cpp: In function 'void Add(std::string, Student*, unsigned int&)':
Main.cpp:94:35: error: no match for 'operator>>' in 'std::basic_stringstream((*(const __string_type*)(& properties)), std::operator|((std::_Ios_Openmode)16u, (std::_Ios_Openmode)8u)) >> firstName'
Main.cpp:94:35: note: candidates are:
/usr/include/c++/4.6/istream:122:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char, _Traits = std::char_traits, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream]
/usr/include/c++/4.6/istream:122:7: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string}' to 'std::basic_istream::__istream_type& (*)(std::basic_istream::__istream_type&) {aka std::basic_istream& (*)(std::basic_istream&)}'
/usr/include/c++/4.6/istream:126:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream, std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios]
/usr/include/c++/4.6/istream:126:7: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string}' to 'std::basic_istream::__ios_type& (*)(std::basic_istream::__ios_type&) {aka std::basic_ios& (*)(std::basic_ios&)}'
/usr/include/c++/4.6/istream:133:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream]
/usr/include/c++/4.6/istream:133:7: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string}' to 'std::ios_base& (*)(std::ios_base&)'
/usr/include/c++/4.6/istream:169:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char, _Traits = std::char_traits, std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream]
/usr/include/c++/4.6/istream:169:7: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string}' to 'bool&'
/usr/include/c++/4.6/istream:173:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char, _Traits = std::char_traits]

 

 

Here is the function it is complaining about:

void Add(std::string properties, Student theStudents[], unsigned int& numberElements)
{
	// temporary attributes to read in from the properties string
	std::string firstName, lastName, idNumber, classification, major;
	
	// fill the attributes from the information in the properties string
	std::stringstream(properties) >> firstName >> lastName >> idNumber >> classification >> major;

	bool alreadyAdded = false;

	// Only create the student if the idNumber is not already assigned
	for(unsigned int i = 0; i<numberElements; i++)
	{
		if(idNumber == theStudents[i].GetProperty(Student::IdNumber))
		{
			std::cout << "Error! ID Number already assigned." <<std::endl;
			alreadyAdded = true;
		}
	}

	if(!alreadyAdded)
	{
		theStudents[numberElements].Create(firstName, lastName, idNumber, classification, major);
		numberElements++;
	}
}

 

Visual Studio 2012 has absolutely zero problem with this.

 

From the error it seems it does not like me to do this:

// fill the attributes from the information in the properties string
	std::stringstream(properties) >> firstName >> lastName >> idNumber >> classification >> major;

 

Though I'm lost on why Visual Studio 2012 has no problem with that but their compiler absolutely hates that?  Maybe I've always been wrong to do that really that's how I've always done it and not 100% sure of a clean solution to not do that.

 

Any ideas on why their compiler throws a fit about this but Visual Studio 2012 doesn't?

 

EDIT: I just tested it out using latest version of gcc and it complained about it also.  What's Visual Studio 2012 compiler doing different here that it has zero problem?  have I been using a C++11 feature of stringstream and actually not know it and the other compilers don't have that feature implemented yet?  I'd appreciate any help here.

 

Thanks.

 

NOTE: The assignment doesn't have to deal with this command I/O, I've already implemented, tested, and finished the assignments major details.

Edited by Chad Smith
0

Share this post


Link to post
Share on other sites

Change your code to actually create a stringstream object

std::stringstream ss(properties);
ss>> firstName;

Yea that's what I ended up doing instead when I actually thought about what I was actually doing.  Guess that's what I get for getting used to one single compiler too much and not knowing what different compilers features have right now.

0

Share this post


Link to post
Share on other sites

Any ideas on why their compiler throws a fit about this but Visual Studio 2012 doesn't?

This is legal C++11 code, but not legal C++03 code. In C++11 there's a operator>> overload that takes an rvalue reference to a std::istream as the left hand side. In C++03 there's only a operator>> overload for a non-const lvalue reference to a std::istream on the left hand side, and a temporary can't be bound to a non-const lvalue reference. IIRC, even the non-C++11 versions of MSVC will accept this kind of code because they have an extension that allows binding a temporary to a non-const lvalue reference.
1

Share this post


Link to post
Share on other sites

Any ideas on why their compiler throws a fit about this but Visual Studio 2012 doesn't?

This is legal C++11 code, but not legal C++03 code. In C++11 there's a operator>> overload that takes an rvalue reference to a std::istream as the left hand side. In C++03 there's only a operator>> overload for a non-const lvalue reference to a std::istream on the left hand side, and a temporary can't be bound to a non-const lvalue reference. IIRC, even the non-C++11 versions of MSVC will accept this kind of code because they have an extension that allows binding a temporary to a non-const lvalue reference.

Thanks for letting me know about this.  That seems like it would answer my question fully on the subject.  Appreciate it.

0

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