how to upgrade gcc to c++11 in ubuntu?
how to upgrade gcc to c++11 in ubuntu? shall I face any problem after upgrading my present gcc?
I am trying to run this code.
`
int main()
{
using namespace std;
int n[5];
//cout << " please enter a character : ";
//cin >> x;
for(int m:n)
cout << m <<" ";
}
this is my warning.
1.cpp: In function ‘int main()’:
1.cpp:15:12: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
for(int m:n)
^
gcc
add a comment |
how to upgrade gcc to c++11 in ubuntu? shall I face any problem after upgrading my present gcc?
I am trying to run this code.
`
int main()
{
using namespace std;
int n[5];
//cout << " please enter a character : ";
//cin >> x;
for(int m:n)
cout << m <<" ";
}
this is my warning.
1.cpp: In function ‘int main()’:
1.cpp:15:12: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
for(int m:n)
^
gcc
@Kulfy I am using g++ 1.cpp
– NAZMUL HUSSAIN
Dec 17 at 12:18
add a comment |
how to upgrade gcc to c++11 in ubuntu? shall I face any problem after upgrading my present gcc?
I am trying to run this code.
`
int main()
{
using namespace std;
int n[5];
//cout << " please enter a character : ";
//cin >> x;
for(int m:n)
cout << m <<" ";
}
this is my warning.
1.cpp: In function ‘int main()’:
1.cpp:15:12: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
for(int m:n)
^
gcc
how to upgrade gcc to c++11 in ubuntu? shall I face any problem after upgrading my present gcc?
I am trying to run this code.
`
int main()
{
using namespace std;
int n[5];
//cout << " please enter a character : ";
//cin >> x;
for(int m:n)
cout << m <<" ";
}
this is my warning.
1.cpp: In function ‘int main()’:
1.cpp:15:12: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
for(int m:n)
^
gcc
gcc
asked Dec 16 at 20:35
NAZMUL HUSSAIN
31
31
@Kulfy I am using g++ 1.cpp
– NAZMUL HUSSAIN
Dec 17 at 12:18
add a comment |
@Kulfy I am using g++ 1.cpp
– NAZMUL HUSSAIN
Dec 17 at 12:18
@Kulfy I am using g++ 1.cpp
– NAZMUL HUSSAIN
Dec 17 at 12:18
@Kulfy I am using g++ 1.cpp
– NAZMUL HUSSAIN
Dec 17 at 12:18
add a comment |
2 Answers
2
active
oldest
votes
Just add a flag and compile it using
g++ -std=c++11 1.cpp
Explanation:
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
this works. thank you so much @kulfy
– NAZMUL HUSSAIN
Dec 17 at 12:26
add a comment |
You compile it with g++ -std=c++11
or g++ -std=gnu++11
to tell the compiler that you want that standard. This is shown in the error message you have.
that does not work. this also gives error.
– NAZMUL HUSSAIN
Dec 17 at 12:23
Which error does it give?
– vidarlo
Dec 17 at 12:25
actually i have to use g++ instead of gcc. it works. thanks
– NAZMUL HUSSAIN
Dec 17 at 12:28
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1102404%2fhow-to-upgrade-gcc-to-c11-in-ubuntu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just add a flag and compile it using
g++ -std=c++11 1.cpp
Explanation:
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
this works. thank you so much @kulfy
– NAZMUL HUSSAIN
Dec 17 at 12:26
add a comment |
Just add a flag and compile it using
g++ -std=c++11 1.cpp
Explanation:
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
this works. thank you so much @kulfy
– NAZMUL HUSSAIN
Dec 17 at 12:26
add a comment |
Just add a flag and compile it using
g++ -std=c++11 1.cpp
Explanation:
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
Just add a flag and compile it using
g++ -std=c++11 1.cpp
Explanation:
-std=
Determine the language standard. This option is currently only
supported when compiling C or C++.
c++11
c++0x
The 2011 ISO C++ standard plus amendments. The name c++0x is
deprecated.
edited Dec 17 at 12:36
answered Dec 17 at 12:24
Kulfy
3,13531039
3,13531039
this works. thank you so much @kulfy
– NAZMUL HUSSAIN
Dec 17 at 12:26
add a comment |
this works. thank you so much @kulfy
– NAZMUL HUSSAIN
Dec 17 at 12:26
this works. thank you so much @kulfy
– NAZMUL HUSSAIN
Dec 17 at 12:26
this works. thank you so much @kulfy
– NAZMUL HUSSAIN
Dec 17 at 12:26
add a comment |
You compile it with g++ -std=c++11
or g++ -std=gnu++11
to tell the compiler that you want that standard. This is shown in the error message you have.
that does not work. this also gives error.
– NAZMUL HUSSAIN
Dec 17 at 12:23
Which error does it give?
– vidarlo
Dec 17 at 12:25
actually i have to use g++ instead of gcc. it works. thanks
– NAZMUL HUSSAIN
Dec 17 at 12:28
add a comment |
You compile it with g++ -std=c++11
or g++ -std=gnu++11
to tell the compiler that you want that standard. This is shown in the error message you have.
that does not work. this also gives error.
– NAZMUL HUSSAIN
Dec 17 at 12:23
Which error does it give?
– vidarlo
Dec 17 at 12:25
actually i have to use g++ instead of gcc. it works. thanks
– NAZMUL HUSSAIN
Dec 17 at 12:28
add a comment |
You compile it with g++ -std=c++11
or g++ -std=gnu++11
to tell the compiler that you want that standard. This is shown in the error message you have.
You compile it with g++ -std=c++11
or g++ -std=gnu++11
to tell the compiler that you want that standard. This is shown in the error message you have.
edited Dec 17 at 12:30
answered Dec 16 at 20:40
vidarlo
8,85342442
8,85342442
that does not work. this also gives error.
– NAZMUL HUSSAIN
Dec 17 at 12:23
Which error does it give?
– vidarlo
Dec 17 at 12:25
actually i have to use g++ instead of gcc. it works. thanks
– NAZMUL HUSSAIN
Dec 17 at 12:28
add a comment |
that does not work. this also gives error.
– NAZMUL HUSSAIN
Dec 17 at 12:23
Which error does it give?
– vidarlo
Dec 17 at 12:25
actually i have to use g++ instead of gcc. it works. thanks
– NAZMUL HUSSAIN
Dec 17 at 12:28
that does not work. this also gives error.
– NAZMUL HUSSAIN
Dec 17 at 12:23
that does not work. this also gives error.
– NAZMUL HUSSAIN
Dec 17 at 12:23
Which error does it give?
– vidarlo
Dec 17 at 12:25
Which error does it give?
– vidarlo
Dec 17 at 12:25
actually i have to use g++ instead of gcc. it works. thanks
– NAZMUL HUSSAIN
Dec 17 at 12:28
actually i have to use g++ instead of gcc. it works. thanks
– NAZMUL HUSSAIN
Dec 17 at 12:28
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1102404%2fhow-to-upgrade-gcc-to-c11-in-ubuntu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@Kulfy I am using g++ 1.cpp
– NAZMUL HUSSAIN
Dec 17 at 12:18