1

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!

Mingjie Li
  • 37
  • 1
  • 5
  • 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 Oct 12 '16 at 07:13
  • gcc -std=c++0x does not work? – JohnB Oct 12 '16 at 07:13
  • 1
    Possible duplicate of [How do I enable C++11 in gcc?](http://stackoverflow.com/questions/16886591/how-do-i-enable-c11-in-gcc) – Humam Helfawi Oct 12 '16 at 07: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. @JohnB – Mingjie Li Oct 12 '16 at 07: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 !@HumamHelfawi – Mingjie Li Oct 12 '16 at 07:38
  • You can see [here](http://gcc.gnu.org/gcc-4.4/cxx0x_status.html) which C++11 features are supported by g++4.4.7. Unfortunately, nullptr isn't one of them. – Bob__ Oct 12 '16 at 07:52
  • If nullptr is the only thing missing, you can provide a definition compatible with the standard. But I think your time would be better spent convincing your sysadmin to install some newer compilers! – Toby Speight Oct 12 '16 at 08:03

1 Answers1

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.

bolov
  • 72,283
  • 15
  • 145
  • 224
  • @MingjieLi you are welcome. Which solution worked for you? – bolov Oct 12 '16 at 10:34
  • probably it is your idea of installing locally. Later, I note that our linux(redhat) system have the Redhat Developer Toolset which could provide the required environment. – Mingjie Li Oct 13 '16 at 11:18