Question Authors' Forum

C++

 
Picture of Richard Lobb
Re: C++
by Richard Lobb - Wednesday, 20 September 2017, 8:01 PM
 

That's not really an error. g++ defaults to C++98 mode in versions prior to 6.1. The for syntax you're using isn't part of the C++98 standard.

If you want to run a different standard, you have lots of options:

  1. Upgrade g++ to version 6.1 or later on Jobe, if this is available for the version of Linux that the Jobe server is running.
  2. Change the default compile options for g++ within Jobe to whichever standard you wish to teach. For example, you might wish to add the compile option -std=c++11. The compile options for C++ are set in the file <jobe_home>/application/libraries/cpp_task.php.
  3. Change the compile options in the CodeRunner language prototype(s) you're using by entering a JSON string like {"compileargs": ["-std=c++11"]} into the sandbox parameters, which are in the Advanced Customisation section of the author's form. This is documented in the on-line help.
  4. Define new question prototypes for C++ that select your preferred mode, as in (3).
  5. Customise just the questions in which you wish to allow the non-default behaviour, as in (3).
Options 2 and 3 will need to be re-implemented if you upgrade Jobe or CodeRunner respectively.

My preference is (4) but you need to understand question prototypes properly if you're going to attempt that.

Richard