I am studying a algorithm code which uses some c++11 features, however my linux system only has the gcc4.4.7 and I donot have permission to update this version. I was told that by running some kind of scripts can solve this problem, that means using gcc4.4.7 can still compile the c++ code which has the c++11 features.
my problem is that currently I only have gcc4.4.7 in linux system, so I wander if there is a solution that can help me compile a algorithm code which uses the c++11 features like the keyword "nullptr","constexpr" and so on, just using gcc4.4.7.
By the way,I have already know that gcc4.7 and above can support c++11.
Thank you very much!
-
You where told by whom? AFAIK you need a compiler which supports c++11 to compile c++11 so this won't be possible.Hayt– Hayt2016年10月12日 07:13:22 +00:00Commented Oct 12, 2016 at 7:13
-
gcc -std=c++0x does not work?JohnB– JohnB2016年10月12日 07:13:29 +00:00Commented Oct 12, 2016 at 7:13
-
1Possible duplicate of How do I enable C++11 in gcc?Humam Helfawi– Humam Helfawi2016年10月12日 07:14:21 +00:00Commented Oct 12, 2016 at 7:14
-
for example, There is a piece of code that uses the "nullptr" which was introduced in c++ 11, so using the "gcc -std=c++0x" doesn't work, the "nullptr" would be recognized undeclared. @JohnBMingjie Li– Mingjie Li2016年10月12日 07:30:45 +00:00Commented Oct 12, 2016 at 7:30
-
my problem is not like the " How do I enable C++11 in gcc?". Currently, I only have gcc4.4.7, but a algorithm code I am studying uses the c++11 features like the keyword "nullptr","constexpr" and so on. So, I wonder if there is a solution that can help me compile this algorithm code only using the gcc4.4.7. Thank you !@HumamHelfawiMingjie Li– Mingjie Li2016年10月12日 07:38:32 +00:00Commented Oct 12, 2016 at 7:38
1 Answer 1
If the compiler doesn't support a language feature, there is no magic "script" to run to alter the compiler's understanding of the code. As seen here some core C++11 features are not available in gcc 4.4.
So what can you do?
Ask your sysadmin to give you temporary permission to install, or ask him to install it.
You could install the latest gcc locally on your account. This needs less permissions than the classical install.
Alternately, you can install gcc from source in a local directory. This should be 100% doable without any special permission (other than write on your home dir)
Alternately, if the algorithm you are studying doesn't have many sources and doesn't use any library other than boost, you can compile and run it online. You can search for yourself, there are many C++ online compilers. http://melpon.org/wandbox/ is great because it supports multiple source files, the boost libraries and even development versions of future versions of gcc and clang.