diff --git a/judger/uoj_judger/include/uoj_judger.h b/judger/uoj_judger/include/uoj_judger.h index 8938b6f..a034a3d 100644 --- a/judger/uoj_judger/include/uoj_judger.h +++ b/judger/uoj_judger/include/uoj_judger.h @@ -987,6 +987,14 @@ RunCompilerResult compile_cpp11(const string &name, const string &path = work_pa return run_compiler(path.c_str(), "/usr/bin/g++", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++11", NULL); } +RunCompilerResult compile_cpp17(const string &name, const string &path = work_path) { + return run_compiler(path.c_str(), + "/usr/bin/g++", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++17", NULL); +} +RunCompilerResult compile_cpp98(const string &name, const string &path = work_path) { + return run_compiler(path.c_str(), + "/usr/bin/g++", "-o", name.c_str(), "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++98", NULL); +} RunCompilerResult compile_python2(const string &name, const string &path = work_path) { return run_compiler(path.c_str(), "/usr/bin/python2.7", "-E", "-s", "-B", "-O", "-c", @@ -1000,7 +1008,7 @@ RunCompilerResult compile_python3(const string &name, const string &path = work_ RunCompilerResult compile(const char *name) { string lang = conf_str(string(name) + "_language"); - if ((lang == "C++" || lang == "C++11" || lang == "C") && has_illegal_keywords_in_file(work_path + "/" + name + ".code")) + if ((lang == "C++" || lang == "C++11" || lang == "C++17" || lang == "C++98" || lang == "C") && has_illegal_keywords_in_file(work_path + "/" + name + ".code")) { RunCompilerResult res; res.type = RS_DGS; @@ -1017,6 +1025,12 @@ RunCompilerResult compile(const char *name) { if (lang == "C++11") { return compile_cpp11(name); } + if (lang == "C++17") { + return compile_cpp17(name); + } + if (lang == "C++98") { + return compile_cpp98(name); + } if (lang == "Python2") { return compile_python2(name); } @@ -1046,12 +1060,20 @@ RunCompilerResult compile_pas_with_implementer(const string &name, const string } RunCompilerResult compile_cpp_with_implementer(const string &name, const string &path = work_path) { return run_compiler(path.c_str(), - "/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", NULL); + "/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++14", NULL); +} +RunCompilerResult compile_cpp98_with_implementer(const string &name, const string &path = work_path) { + return run_compiler(path.c_str(), + "/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++98", NULL); } RunCompilerResult compile_cpp11_with_implementer(const string &name, const string &path = work_path) { return run_compiler(path.c_str(), "/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++11", NULL); } +RunCompilerResult compile_cpp17_with_implementer(const string &name, const string &path = work_path) { + return run_compiler(path.c_str(), + "/usr/bin/g++", "-o", name.c_str(), "implementer.cpp", "-x", "c++", (name + ".code").c_str(), "-lm", "-O2", "-DONLINE_JUDGE", "-std=c++17", NULL); +} /* RunCompilerResult compile_python2(const string &name, const string &path = work_path) { return run_compiler(path.c_str(), @@ -1083,6 +1105,12 @@ RunCompilerResult compile_with_implementer(const char *name) { if (lang == "C++11") { return compile_cpp11_with_implementer(name); } + if (lang == "C++17") { + return compile_cpp17_with_implementer(name); + } + if (lang == "C++98") { + return compile_cpp98_with_implementer(name); + } if (lang == "C") { return compile_c_with_implementer(name); } diff --git a/web/app/controllers/faq.php b/web/app/controllers/faq.php index cf3ea12..b94bba5 100644 --- a/web/app/controllers/faq.php +++ b/web/app/controllers/faq.php @@ -54,7 +54,7 @@
默认的测评环境是 Ubuntu Linux 20.04 LTS x64。
C的编译器是 gcc 9.4.0,编译命令:gcc code.c -o code -lm -O2 -DONLINE_JUDGE
。
C++的编译器是 g++ 9.4.0,编译命令:g++ code.cpp -o code -lm -O2 -DONLINE_JUDGE
。如果选择C++11会在编译命令后面添加-std=c++11
。
C++的编译器是 g++ 9.4.0,编译命令:g++ code.cpp -o code -lm -O2 -DONLINE_JUDGE
。默认为 C++14,如果选择特定语言版本会添加 -std=
参数。
Pascal的编译器是 fpc 3.0.4,编译命令:fpc code.pas -O2
。
Python会先编译为优化过的字节码.pyo文件。支持的Python版本分别为Python 2.7和3.8。