Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use -std-c++11 in Eclipse C++

I have this line written in my code

vector<GLfloat> cone1 { 0.0f, 2.4f, -11.0f, /*rotated*/30.0f, -1.5f, 0.0f, 0.0f };

But the errors comes up like in C++98, variable must be initialized by constructor not by {}

I have searched the solution that I should use -std-c++11, but I don't know how to add this in Eclipse?

like image 900
Umair Ayub Avatar asked Jul 07 '13 16:07

Umair Ayub


People also ask

Can you code in C in Eclipse?

Eclipse is popular for Java project development. It also supports C/C++, PHP, Python, Perl, and other web project developments via extensible plug-ins. Eclipse is cross-platform and runs under Windows, Linux and Mac OS.

How do you do C in Eclipse?

Launch Eclipse → Help → Install New Software → In "Work with" field, pull down the drop-down menu and select "Kepler - http://download.eclipse.org/releases/kepler" (or juno for Eclipse 4.2; or helios for Eclipse 3.7). In "Name" box, expand "Programming Language" node ⇒ Check "C/C++ Development Tools" ⇒ "Next" ⇒ ...

How do I run a CPP File in Eclipse?

In Eclipse, go to the "File" menu, then "New", then "Project". Click the "+" sign to expand "C++" to "Managed Make C++ Project" and "Standard Make C++ Project". Choose the former. A dialog box will ask whether to open the C/C++ perspective.

What C compiler does Eclipse use?

Eclipse CDT uses C/C++ Compiler. Hence before we can start using Eclipse CDT for C/C++ development, we need to have a proper GCC compiler on our system. We can either have 'MinGW' or 'Cygwin' compiler on our machine that will be used by eclipse.


1 Answers

You can do this in a few simple steps...

  • Right-click on the the project and select "Properties"
  • Navigate to C/C++ Build -> Settings
  • Select the Tool Settings tab.
  • Navigate to GCC C++ Compiler -> Miscellaneous
  • In the option setting labeled Other Flags add -std=c++11

Now rebuild your project.

Note: this assumes you did not create your project to use GNU Autotools or a makefile.

like image 180
Captain Obvlious Avatar answered Oct 11 '22 00:10

Captain Obvlious