When you are coding in C++ using eclipse IDE (installing CDT plugin)and if you use newer features of C++11 sometimes you might get errors when compiling. Reason for that might be you haven't enabled C++11 in Eclipse CDT. Lets see how to enable C++11 in Eclipse CDT. These steps are given assuming you are using GCC compiler. But steps are more similar to the other compilers as well.
Step 1 : Set up your compiler
- Right click your project and click Properties
- Under C/C++ Build click Settings
- Under GCC C++ Compiler, click Miscellaneous
- In the Other Flags box, append "-std=c++11" to the list of tokens
- Click Apply and OK
Step 2 : Setup CDT's language processor
- Right click your project and click Properties
- Under C/C++ General click "Preprocessor Include Paths, Macros"
- Select the Providers tab
- Select the entry "CDT GCC Built-in Compiler Settings MinGW"
- Uncheck the "Use global provider..." option
- Append "-std=c++0x" to box that says "Command to get compiler specs."
- Move entry "CDT GCC Built-in Compiler Settings MinGW" at the top of the list using the 'Move Up' button on the right.
- Click Apply and then OK.
- Back in your Eclipse workspace, select the Project Menu, C/C++ Index, and click "Re-resolve unresolved includes"
- Restart eclipse
Now you will be able to compile the code without unexpected errors.
No comments:
Post a Comment