how to upgrade gcc to c++11 in ubuntu?












0














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)
^











share|improve this question






















  • @Kulfy I am using g++ 1.cpp
    – NAZMUL HUSSAIN
    Dec 17 at 12:18
















0














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)
^











share|improve this question






















  • @Kulfy I am using g++ 1.cpp
    – NAZMUL HUSSAIN
    Dec 17 at 12:18














0












0








0


0





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)
^











share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 16 at 20:35









NAZMUL HUSSAIN

31




31












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




@Kulfy I am using g++ 1.cpp
– NAZMUL HUSSAIN
Dec 17 at 12:18










2 Answers
2






active

oldest

votes


















0














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.







share|improve this answer























  • this works. thank you so much @kulfy
    – NAZMUL HUSSAIN
    Dec 17 at 12:26



















0














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.






share|improve this answer























  • 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











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
});


}
});














draft saved

draft discarded


















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









0














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.







share|improve this answer























  • this works. thank you so much @kulfy
    – NAZMUL HUSSAIN
    Dec 17 at 12:26
















0














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.







share|improve this answer























  • this works. thank you so much @kulfy
    – NAZMUL HUSSAIN
    Dec 17 at 12:26














0












0








0






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.







share|improve this answer














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.








share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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













0














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.






share|improve this answer























  • 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
















0














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.






share|improve this answer























  • 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














0












0








0






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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

數位音樂下載

When can things happen in Etherscan, such as the picture below?

格利澤436b