How to enable C++11 support in Eclipse? - c++

I know there are a lot of answers, but no one is useful.
Ubuntu 16.04
Eclipse 4.6.2
I have tried every solution including:
Add -std=c++11 or c++14 or c++0x or gnu++0x or gnu++11 in the "Command to get compiler specs".
Add __GXX_EXPERIMENTAL_CXX0X in the "Symbols".
Add __cplusplus and set value to 201402L.
So I just wonder, why can't the developer just design an option to enable it?
Does any one have solution?
Oh am I forgot to rebuild? No.
To provide more information, I use a custom script to build my *.cpp. And I think build options won't affect the recognizance right?
Sorry about missing "11".

While your question is not very clear to me, I would like to recommend using eclipse-cdt
It comes as a plugin for eclipse. Please use the eclipse update manager to install this plugin and get started with your C++ development work.

Related

Can you install multiple C++ compilers on Windows?

Yes, I'm a noob. I have Dev C++ but another tutorial I want to do says to install MinGW Code::Blocks. I just want to see what that one is like, I know I can simply use Dev C++. But, is it possible to just add both to the path and use whichever one I want?
You have a misunderstanding in your question. DevC++ and Code::Blocks are IDEs, not compilers. You definitely can have more than one IDE installed at a time.
That said, the answer to your question as asked is yes, you can install multiple c++ compilers on Windows. But putting more than one in your path is likely to cause problems.

Eclipse Luna Indexer for C++14 with custom makefile

I currently have a C++ project with a custom makefile. I tell eclipse to simply call make and the makefile handles everything. The project builds fine but eclipse keeps highlighting generalized lambda captures as "syntax errors". As far as I understand from this:
https://stackoverflow.com/a/835019/4076418 ,
it's a problem with the CDT Indexer not understanding the C++14 syntax.
I've tried following the answers here:
Eclipse CDT C++11/C++0x support
https://stackoverflow.com/a/13635080/4076418
but they don't handle my case which is Eclipse Luna + a custom makefile project + c++14.
This question is probably related to mine but it has no answer [I also don't have the ability to change the indexer]:
https://stackoverflow.com/q/24950192/4076418
Any ideas on how to get the indexer to recognize c++14 features?
P.S. C++11 features aren't highlighted as syntax errors for some reason. I should also note that I'm using clang 3.4.2 in the makefile; obviously, it supports c++14. The g++ version available though is 4.4.7 so it doesn't support c++14. Could this be the problem somehow? That the CDT uses the system's g++ for the indexer? And if so, how do I change that without having to update g++ (I'm working with limited user privileges and updating it would be a pain)?
AFAIK Eclipse Luna does not support C++14 overall. You will probably need to upgrade to Eclipse Neon. I use neon, the parser works, I don't use custom makefile though
I have used Luna in the past, but even C++11 support was sometimes hard to setup.

Eclipse CDT documentation on C++ autocomplete

I was trying to set up my development environment on Eclipse CDT for C++ and although the auto-complete is working (it finds classes like vector and such) it shows no documentation on C++ stuff, only C stuff (fopen, fclose, malloc) has documentation appearing on the auto-complete.
Some notes:
I'm using Linux Mint and Eclipse Kepler Service Release 1 Build id: 20130919-0819
I had to manually install g++ on my Linux. I used 'sudo apt-get install g++-4.7' to install it
I had to manually place "/usr/include/c++/4.7.3/" on the GCC C++ Compiler Includes in the Tool Settings in the project properties to get it to compile.
Any ideas on how to get the documentation in there?
The help on C is provided by Libhover plugin. The developers tried to support C++ but seems these efforts did not get much traction.
C++ hover is actually installed by default in CDT. If not, you can install it manually (at CDT site look for "Plugins for C/C++ library hover help." and "Plugins for creating hover help from installed C devhelp documentation").
However, it is not enough. To get hovering help similar to C documentation you have to generate Doxygen XML for your library, e.g. for STL. Details are provided in hover documentation

Why can't Eclipse find regex on Mac OSX?

I'm using Eclipse Juno on OSX Mountain Lion and wanted to use std::regex, which I know is a C++11 only feature. When I #include <regex> the IDE says it doesn't exist. Maybe it's good to note that the header regex.h is present /usr/include/, though I see no specific library for it in /usr/lib/ or /usr/local/lib/, though I'm not aware if that's relevant. This is just a side project for fun so I'm not using a customized build system, just a regular C++ project in Eclipse.
I'm not real experienced when it comes to modifying a build process (other than setting include paths, libraries, etc.), especially when an IDE like Eclipse is driving it, but my assumption is that the compiler and linker (GCC G++) isn't configured for C++11, though I've tried various recommendations from SO and the Eclipse forums, like adding -std=c++11, but I just keep seeing output saying that they're unrecognized arguments.
I'm sure someone out there has dealt with this issue. Can anyone help? Thanks in advance.
On mac you have to use the flag:
-stdlib=libc++
and even then I believe generally only clang is updated enough(so use clang instead of gcc), if you've just been using the Xcode updates. You should also make sure that your Xcode command line tools are updated, because I would guess that is the compiler eclipse is using.

A simple "javac" style command-line C/C++ compiler for Windows 7

Over the last couple of months I practiced console programming with Java just with the help of JDK and a text editor of my choice (Notepad++). And I loved the simplicity as a program can be compiled from the command line plainly using javac and run using java.
Now, I'm looking for similar compiler for C/C++, such that I create a .c or .cpp file and compile it in the command prompt, and all it does is create a "native" executable that can be run directly from the command prompt. Thus, without any need of bloated IDE. The reason I'm looking for such simple compiler is because it is going to be used by high-school students so I'm advised to avoid any IDE as far as possible, so students can practice all the concepts of C/C++ languages without having to go for IDE. Which compiler can I use that does this job? also, I must work across all the versions Windows starting from Windows XP.
You can download MinGW which is basically GCC for windows.
Then you can simply gcc somefile.c to create an executable.
http://gcc.gnu.org/gcc is a multi platform c/c++ compiler
Visual Studio includes the ability to compile from the command line. Like others just said you can look at cygwin/MinGW. I would recommended using Code::Blocks or Dev-C++. I know you stated you do not want an IDE, but I would highly suggest a minimalist IDE like the ones I just suggested, or at least SciTE or Notepad++ to get some basic syntax highlighting with the ability to configure build tools if you want as well.
MinGW GCC is definitely the way go, but I would recomend the nuwen.net distro (http://nuwen.net/mingw.html). Haven't used it in a while (yay unix!), but if IIRC, it comes with everything ready to go after unpacking. The official distribution is ... very hard to get working.
A very simple solution woul be cygwin and MinGW, which provides an environment very similar to a UNIX shell. Then you can use the make utilities to compile your program.
You should certainly consider using MinGW GCC, but not by download from the MiNGW web page, unless you are some kind of masochist. Get the one packaged by Twilight Dragon Media at http://tdm-gcc.tdragon.net.
I too use VisualStudio on Windows from the command prompt and use VS Make files as well. That way, I can smb mount my source code from a different machine and perform compiles on several different platforms at once (e.g. Windows, Linux, Solarsi).