Change the compiler of c++ 11

Started by
22 comments, last by Radikalizm 11 years, 4 months ago
How do i change the compiler of C++ 11 in VS12 to codeblocks compiler
Advertisement
Why would you even want to do this? What's wrong with the MSVC compiler provided with VS2012?
If you are still taking your first steps in C++ any modern compiler will do, if you're facing any problems they're most likely due to your own setup, not because of compiler issues.

Learning C++ can be a huge mindf*ck in itself, don't make things even worse for yourself by trying to mess with custom build settings.

I gets all your texture budgets!

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. Then you just indicate the correct bin, lib, include folders in your VS12 settings and you are good to go. Be wary that debugging may not work, and you may also have problems if you try to use a 64-bit compiler with a 32-bit IDE (or even with a 64-bit IDE for that matter). I agree with Radikalizm and unless there is a strong reason you need to change compilers, don't do it.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

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
What is it with the result from VS2012 that is different from codeblocks, or not what you expect or want it to be?
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,

#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;

}
Use CTRL-F5 to start the application inside VS, and the console should remain open.

edit: You also need to do the following steps (copied from a Stack Overflow answer):


Note that this requires the Console (/SUBSYSTEM:CONSOLE) linker option, which you can enable as follows:
1 Open up your project, and go to the Solution Explorer. If you're following along with me in K&R, your "Solution" will be 'hello' with 1 project under it, also 'hello' in bold.
2 Right click on the 'hello" (or whatever your project name is.)
3 Choose "Properties" from the context menu.
4 Choose Configuration Properties>Linker>System.
5 For the "Subsystem" property in the right-hand pane, click the drop-down box in the right hand column.
6 Choose "Console (/SUBSYSTEM:CONSOLE)"
7 Click Apply, wait for it to finish doing whatever it does, then click OK. (If "Apply" is grayed out, choose some other subsystem option, click Apply, then go back and apply the console option. My experience is that OK by itself won't work.)
Ya it is there but when u close it and juz use F5 it closes automatically
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.
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.

This topic is closed to new replies.

Advertisement