C++ compiler and standard

C++ compiler and standard

by a Salem -
Number of replies: 3

Hello,

I want to create a question on CodeRunner of type "C++ program", and I would like to know what is the compiler that CodeRunner is using to compile student's codes, and with which C++ standard.

I would appreciate it if you would provide me with that information.

Thanks in advance.

In reply to a Salem

Re: C++ compiler and standard

by Ivica Lazarevic -
Hello,

Compiler version depends on your platform. In my case it is g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0. 

I found this inside the file <moodle root>/question/type/coderunner/db/builtin_PROTOTYPES.xml

elif language == 'cpp':
cppflags = "-Wall -Werror"
return_code = subprocess.call("g++ {0} -o __tester__ __tester__.cpp".format(cppflags).split())

I don't see that standard is explicitly set, so it sould use default standard for your compiler. In my case it is standard for GCC 11 series -std=gnu++17.
In reply to Ivica Lazarevic

Re: C++ compiler and standard

by Richard Lobb -
Thanks Ivica

The only things I can add to that are:
  1. You can find out what g++ version is running by executing the bash command 'g++ --version' from within a CodeRunner question, e.g. by calling the system function in C++ or os.system in Python.
  2. You can explicitly set -std, or any other compile options, by passing a value for compileargs to the Jobe server. To see how, click customise, then open the advanced customisation section, and click the Help (question mark) button for Sandbox parameters. There's a documented example for setting the C compiler -std option. 
In reply to Richard Lobb

Re: C++ compiler and standard

by a Salem -
Dear Ivica and Richard,

Thank you for your answer. It really helped.