Closed bangoc closed 2 years ago
Sorry, but I really don't wish to change the Jobe code base to use different default options. What about all the users who actually want the existing behaviour, such as myself?
I think it's a matter of opinion as to whether you should allow students to submit code that generates warnings in an educational environment. I prefer not to allow this. But if you do wish to allow it, you can pass the "-w" compiler option in the run request. Assuming you're using CodeRunner, you can set any compiler options you want in the question authoring form (Advanced customisation > Sandbox > Parameters). You can put these preferred options into a custom question prototype if you wish to use them generally.
That does leave the question of allowing gets. You're right that merely turning off compiler warnings still results in a linker warning that "the `gets' function is dangerous and should not be used". I feel quite strongly that that's excellent advice that should be respected. Why not use fgets instead, which has the buffer length as a parameter? However, if you really wish to allow students to use gets, there is a way forward that doesn't involve changing the Jobe code base.
The documentation has a section "supporting or implementing new languages". This shows how you can construct your own version of a C question type via a Python script that fully controls the compilation and execution of the C code on the server. With that approach you can use any compiler or linker arguments you like and can filter out any output you don't wish to pass back to CodeRunner. Output to stderr results in aborting the CodeRunner job but you can yourself control what output goes to stdout and what to stderr.
The benefit of that approach is that you have complete control over the process from within the question type rather than modifying the code base. If you don't wish to use a Python script, you can use a C template instead.
The advice is highly respectable, of course, but the philosophy of C programmers know what are they doing can be higher, at least in my opinion. The point of "gets" is simplicity, gets is simpler: it requires only one parameter and in some cases it's good to delete the '\n'. Yes i still want to allow gets, and maybe so do the people who are still relying on older standards. I feel c_via_python can solve my problems, thanks you a lot for your response!
For compiling languages, it seem fair enough to accept solutions with warnings, because warnings by nature are not errors, codes with warnings totally can works correctly (ofcourse as probably can contain logical mistake). For example the gets function, although everybody knows about the warning that it can not be used safely, but in educational exercises with explicit limits in requirements the situations are different, but there are no way to make the linker silence about this and thereafter Jobe treats warnings as errors, in combination people have no choices, and it's not right in the open world, so i think it should be fixed, and i tend to fix the problem with C task first in this commit.