• 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
Sugavanas

Change the compiler of c++ 11

23 posts in this topic

Thanks but i want to change the compiler because I use a book which uses c++ to teach but i feel comfortable using vs 12 and i also need the same results as it is in code blocks. thats why
0

Share this post


Link to post
Share on other sites
The thing is in codeblocks the console does not end after it starts but in vs it just closes and i can't see a thing, for example use this code in vs and codeblocks in an console app,
[CODE]
#include <iostream>
using namespace std;
int main()
{
//Chapter 2 : Additon code

//Chapter 2 : Divisional code
int first, second;
cout << "Dividing 28 by 14." << endl;
first = 28;
second = 14;
cout << "Quotient " << first / second << endl;
cout << "Remainder " << first % second << endl;
cout << "Dividing 32 by 6." << endl;
first = 32;
second = 6;
cout << "Quotient " << first / second << endl;
cout << "Remainder " << first % second << endl;
//chapter 2 : char
cout << "Char " << first / second << endl;
char ch;
ch = 'a';
cout << ch << endl;
char c;
c = '\0';
cout << c << endl;
cout << "hif" << endl;
return 0;

}
[/CODE]
0

Share this post


Link to post
Share on other sites
As LennyLen said, you can keep the console open after exit in VS also. This is not the result of the compiler, but the result of how the IDE handles your application. So even if you would have used the VS IDE with another compiler, it is still VS that is either keeping the console open or closing it after the program exits.

For example, in VS you can run the application with (F5) or without (CTRL-F5) the debugger. If you run the application with the debugger, the IDE will close the console immediately, and if you run it without the debugger, it will keep the console open after it exits.
2

Share this post


Link to post
Share on other sites
Alternately you can just set a break point at the closing brace for the main() function. Just click the margin on the left of the closing brace in the IDE.
2

Share this post


Link to post
Share on other sites
Alternatively you can pause your program at the end using something like std::cin.get(); or getchar();

Cheers!
2

Share this post


Link to post
Share on other sites
If this is a windows only application you can add the following line at the bottom of the main
[code]
stytem( "pause" );
[/code]

Otherwise should work on any system
[code]
std::cout << "press the enter key to continue" << std::endl;
char c;
std::cin >> c;
[/code]
0

Share this post


Link to post
Share on other sites
I really can't recommend [b]against [/b]
[CODE]
system("pause");
[/CODE]
enough. Especially when you can have highly portable functions available to you in the standard library.

I prefer to use something like:
[CODE]
void pause_console(char const* message)
{
std::cout << message << std::flush;
std::cin.ignore(std::numeric_limits< std::streamsize >::max(), '\n');
}
[/CODE]

Benefits? Independent of IDE in use and is platform independent.

Incidentally, the MSVC compiler in VS2012 is perfectly fine. I would recommend sticking with it on the Windows platform. In fact, the only reason I use g++ on Windows is to experiment with variadic templates among other things that VS doesn't yet support. For the simple stuff, though, don't sweat over compiler differences too much. Your results should be the same regardless.
1

Share this post


Link to post
Share on other sites
[quote name='BigDaveDev' timestamp='1353870914' post='5003980']
I really can't recommend [b]against [/b]
[CODE]
system("pause");
[/CODE]
enough. Especially when you can have highly portable functions available to you in the standard library.

I prefer to use something like:
[CODE]
void pause_console(char const* message)
{
std::cout << message << std::flush;
std::cin.ignore(std::numeric_limits< std::streamsize >::max(), '\n');
}
[/CODE]

Benefits? Independent of IDE in use and is platform independent.

Incidentally, the MSVC compiler in VS2012 is perfectly fine. I would recommend sticking with it on the Windows platform. In fact, the only reason I use g++ on Windows is to experiment with variadic templates among other things that VS doesn't yet support. For the simple stuff, though, don't sweat over compiler differences too much. Your results should be the same regardless.
[/quote]

FYI, Microsoft released CTP about a month ago (http://blogs.msdn.com/b/vcblog/archive/2012/11/02/visual-c-c-11-and-the-future-of-c.aspx) that supports variadic templates and few more nice features of C++11. They haven't yet updated Intellisense so its a bit weird because you will get syntax error in some places but it will compile. I used it in my main project for a while and didn't encounter any errors.

It can be downloaded from here: http://www.microsoft.com/en-us/download/details.aspx?id=35515

I'm not sure when these changes will be incorporated into main version but lets hope it will be soon :)
1

Share this post


Link to post
Share on other sites
[quote name='noizex' timestamp='1354041989' post='5004608']
that supports variadic templates and few more nice features of C++11.
[/quote]

Wow, thanks for that info! I just installed the first service pack for VS2012, but I didn't see anything about variadic templates in the description - but then again, that was probably because I stopped reading after "enable C++ applications to target Windows XP from Visual Studio 2012". I was so waiting for this. Now I can finally say that there is no reason left to finally ditch the very outdated VS2008 and move to VS2012.

I just went back and read through the MSDN blocks, but none of them said anything about upgrades to the compiler... So I guess I just have to try it ;) Thanks again for the info
0

Share this post


Link to post
Share on other sites
[quote name='brx' timestamp='1354051093' post='5004675']
[quote name='noizex' timestamp='1354041989' post='5004608']
that supports variadic templates and few more nice features of C++11.
[/quote]

Wow, thanks for that info! I just installed the first service pack for VS2012, but I didn't see anything about variadic templates in the description - but then again, that was probably because I stopped reading after "enable C++ applications to target Windows XP from Visual Studio 2012". I was so waiting for this. Now I can finally say that there is no reason left to finally ditch the very outdated VS2008 and move to VS2012.

I just went back and read through the MSDN blocks, but none of them said anything about upgrades to the compiler... So I guess I just have to try it ;) Thanks again for the info
[/quote]

Its CTP so its a preview of new features that haven't yet been incorporated into main MSVC compiler. You will have to switch compiler in project options to use it. Its supposed to not be used for real purposes until they release the real version, but I used it in my project without problems, as I mentioned already.
0

Share this post


Link to post
Share on other sites
[url=http://www.microsoft.com/visualstudio/eng/visual-studio-update]The official Update 1[/url] was just released yesterday. It's not a preview anymore.
1

Share this post


Link to post
Share on other sites
[quote name='SiCrane' timestamp='1354058712' post='5004734']
[url="http://www.microsoft.com/visualstudio/eng/visual-studio-update"]The official Update 1[/url] was just released yesterday. It's not a preview anymore.
[/quote]

This update does not contain the features from the november CTP though :(
0

Share this post


Link to post
Share on other sites
[quote name='noizex' timestamp='1354041989' post='5004608']
[quote name='BigDaveDev' timestamp='1353870914' post='5003980']
-snip -
[/quote]

FYI, Microsoft released CTP about a month ago ([url="http://blogs.msdn.com/b/vcblog/archive/2012/11/02/visual-c-c-11-and-the-future-of-c.aspx"]http://blogs.msdn.co...uture-of-c.aspx[/url]) that supports variadic templates and few more nice features of C++11. They haven't yet updated Intellisense so its a bit weird because you will get syntax error in some places but it will compile. I used it in my main project for a while and didn't encounter any errors.

It can be downloaded from here: [url="http://www.microsoft.com/en-us/download/details.aspx?id=35515"]http://www.microsoft...s.aspx?id=35515[/url]

I'm not sure when these changes will be incorporated into main version but lets hope it will be soon [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]

Thanks! =D

Worth noting, though, that the standard library is NOT updated with this CTP. This means that the following won't work:
[CODE]
std::vector< int > my_ints = {1, 2, 3, 4, 5}; // won't compile

// Neither will this...
for(auto i: {1, 2, 3, 4, 5})
{
std::cout << i << ' ';
}
[/CODE]

since that relies on library features... Still, getting closer!! At least now I can begin prep-ing my g++4.7 projects for MSVC a little at a time
0

Share this post


Link to post
Share on other sites
[quote name='BigDaveDev' timestamp='1354096900' post='5004906']
[quote name='noizex' timestamp='1354041989' post='5004608']
[quote name='BigDaveDev' timestamp='1353870914' post='5003980']
-snip -
[/quote]

FYI, Microsoft released CTP about a month ago ([url="http://blogs.msdn.com/b/vcblog/archive/2012/11/02/visual-c-c-11-and-the-future-of-c.aspx"]http://blogs.msdn.co...uture-of-c.aspx[/url]) that supports variadic templates and few more nice features of C++11. They haven't yet updated Intellisense so its a bit weird because you will get syntax error in some places but it will compile. I used it in my main project for a while and didn't encounter any errors.

It can be downloaded from here: [url="http://www.microsoft.com/en-us/download/details.aspx?id=35515"]http://www.microsoft...s.aspx?id=35515[/url]

I'm not sure when these changes will be incorporated into main version but lets hope it will be soon [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]

Thanks! =D

Worth noting, though, that the standard library is NOT updated with this CTP. This means that the following won't work:
[CODE]
std::vector< int > my_ints = {1, 2, 3, 4, 5}; // won't compile

// Neither will this...
for(auto i: {1, 2, 3, 4, 5})
{
std::cout << i << ' ';
}
[/CODE]

since that relies on library features... Still, getting closer!! At least now I can begin prep-ing my g++4.7 projects for MSVC a little at a time
[/quote]

Yeah they clearly stated that std containers were not updated, but will be for the final release. Its still worth it, just for variadic templates. I rewrote some crazy factory code that had like 200 lines of code + weird macro magic to support variable number of constructor parameters into something that takes one screen of clean code without any macros :)
0

Share this post


Link to post
Share on other sites
[quote name='Radikalizm' timestamp='1353669530' post='5003446']Why would you even want to do this? What's wrong with the MSVC compiler provided with VS2012?[/quote]One valid reason would be that C++11 support in MSVC (even CTP) is very meager compared to its competitors.

Though I somewhat agree with you insofar as C++98 already has a lot to swallow for a beginner, and seeing how hardly any project uses C++11 features, it is probably wise to learn a standard that "works" first. On the other hand C++11 is really a lot easier in many respects, so if you care mostly for your own projects, it may be a viable option to learn the "proper thing" right away.
After roughly two years of on/off use and a year of exclusively using what's supported in C++11, I can hardly imagine going back (at least voluntarily!) to a compiler or language version that doesn't have auto, lambda, delegating constructors, variadic templates, template typedefs, or range based loops. Some C++11 features may be debatable, but most of it is just... awesome.

[quote name='Bacterius' timestamp='1353669683' post='5003447']There is no "codeblocks compiler", did you mean gcc? If so, it does not exist as such under Windows, but you can use MinGW which is a POSIX wrapper to run gcc on windows.[/quote]Allow me a small, admittedly pedantic, objection: There is a "Code::Blocks compiler" insofar as the convenience package that most people use is the one that has GCC-MinGW bundled. Or at least, this just looks like "the Code::Blocks compiler" to the casual observer.

Also, note that MinGW is very much [i]not [/i]a POSIX wrapper. Cygwin is such a thing, but MinGW states that they explicitly try [i]not to be Cygwin, [/i]but to provide a more or less minimal wrapper around MSVCRT.
2

Share this post


Link to post
Share on other sites
[quote name='samoth' timestamp='1354101721' post='5004926']
Also, note that MinGW is very much not a POSIX wrapper. Cygwin is such a thing, but MinGW states that they explicitly try not to be Cygwin, but to provide a more or less minimal wrapper around MSVCRT.
[/quote]
Thanks, I believe I confused the two!
0

Share this post


Link to post
Share on other sites
[quote name='samoth' timestamp='1354101721' post='5004926']
One valid reason would be that C++11 support in MSVC (even CTP) is very meager compared to its competitors.

Though I somewhat agree with you insofar as C++98 already has a lot to swallow for a beginner, and seeing how hardly any project uses C++11 features, it is probably wise to learn a standard that "works" first. On the other hand C++11 is really a lot easier in many respects, so if you care mostly for your own projects, it may be a viable option to learn the "proper thing" right away.
After roughly two years of on/off use and a year of exclusively using what's supported in C++11, I can hardly imagine going back (at least voluntarily!) to a compiler or language version that doesn't have auto, lambda, delegating constructors, variadic templates, template typedefs, or range based loops. Some C++11 features may be debatable, but most of it is just... awesome.
[/quote]VS2010 already had auto and lambda. VS2012 has range based loops (along with a big bunch of other stuff). The only missing thing I think would be important for a newbie is uniform initialization, and basic support for that is already in the update release (though to really make use of it, they still have to fix standard library containers to support it). You aren't giving up much by using the VS compiler anymore.
0

Share this post


Link to post
Share on other sites
[quote name='samoth' timestamp='1354101721' post='5004926']
One valid reason would be that C++11 support in MSVC (even CTP) is very meager compared to its competitors.

Though I somewhat agree with you insofar as C++98 already has a lot to swallow for a beginner, and seeing how hardly any project uses C++11 features, it is probably wise to learn a standard that "works" first. On the other hand C++11 is really a lot easier in many respects, so if you care mostly for your own projects, it may be a viable option to learn the "proper thing" right away.
After roughly two years of on/off use and a year of exclusively using what's supported in C++11, I can hardly imagine going back (at least voluntarily!) to a compiler or language version that doesn't have auto, lambda, delegating constructors, variadic templates, template typedefs, or range based loops. Some C++11 features may be debatable, but most of it is just... awesome.
[/quote]

Agreed, C++ 11 is awesome and I've been using its features extensively as well. The lack of full C++11 support in VS2012 is frustrating at some times (especially when it comes to variadic templates) but it's not a deal-breaker to me.
The OP however is, if I remember correctly, a relatively young person who hasn't done any or at least not much programming at all. He will be writing very simple programs in the beginning and definitely won't be needing any 'fancy' C++11 features which aren't supported by VS2012 yet at all for quite some time.
Visual Studio is a good choice as a beginner IDE since it has a lot of features which can make a programmer's life a lot easier, so in my opinion it would be a much better idea for the OP to work in a more friendly environment while sacrificing some compiler features he won't be needing anytime soon, instead of letting him use an environment that's maybe worse for beginners just so he can have more C++11 support. Once he's at the point where he's comfortable with C++ and programming in general there will probably be an updated version of MSVC available with better C++11 support, or if that's not the case he will be comfortable enough with the language to switch compilers and IDEs without any trouble.
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