Here are some common questions we’ve had from users writing C++ applications using Cloud9:
Does Cloud9 support C++ 11?
Yes. As of writing we use GCC version 4.8.4 which supports all functionality of C++ 11. To use C++11 functions you will need to pass the flag
-std=c++11 to the GCC compiler. You can add this to your runner with the following steps:
- In the runner window click where it says “Runner: C++ (simple)”.
- Click edit runner
- Add this flag just after
g++on line 7. So the complete line should look like:
"/usr/bin/g++ -std=c++11 $file -o runme; chmod 755 $file_path/runme; $file_path/runme"
- Save the file in the default location as the filename it recommends.
- Close the file and runner window (sometimes the runner doesn’t update if you don’t close it)
- Re-run your file.
Does Cloud9 Support C++ 14?
Yes, gcc 5.x is available in the C++ workspace type, although we don’t support it by default at this time, you can edit the C++ runner or create a new runner.
The runner command should look something like:
"/usr/bin/g++-5 -std=c++14 $file -o runme; chmod 755 $file_path/runme; $file_path/runme"
Notice that it uses g+±5 instead of just g++ and has the flag
-std=c++14 those are the only differences between it and the default c++ runner.
The ‘auto’ keyword is not working with Cloud9
When running your C++ application using the auto keyword you may see an error similar to:
error: ‘x’ does not name a type
This is happening because the auto keyword is a C++11 feature. You’ll need to enable C++11 support in the runner. You can do this by following the steps under the “Does Cloud9 support C++ 11” FAQ heading above.