C++ compiler and standard

C++ compiler and standard

de a Salem -
Número de respuestas: 3


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.

En respuesta a a Salem

Re: C++ compiler and standard

de Ivica Lazarevic -

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.
En respuesta a Ivica Lazarevic

Re: C++ compiler and standard

de 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.