diff --git a/learn/test.cpp b/learn/test.cpp index 9b984830..2f6f9ccb 100644 --- a/learn/test.cpp +++ b/learn/test.cpp @@ -36,9 +36,10 @@ static bool test_exercise(std::ostream &os, int n, const char *log) { bool test_exercise(int n, const char *log) { if (log) { - auto log_ = fs::absolute(fs::path(XMAKE) / "log" / log); - auto log__ = log_.string(); - return test_exercise(std::fstream(log_, std::ios::out | std::ios::app), n, log__.c_str()); + const auto log_ = fs::absolute(fs::path(XMAKE) / "log" / log); + const auto log__ = log_.string(); + auto file = std::fstream(log_, std::ios::out | std::ios::app); + return test_exercise(file, n, log__.c_str()); } else { return test_exercise(std::cout, n, nullptr); } diff --git a/xmake.lua b/xmake.lua index 5a28afd0..fa3263bd 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,20 +1,19 @@ add_rules("mode.debug", "mode.release") set_encodings("utf-8") +set_warnings("all") +set_languages("cxx17") target("test") set_kind("static") - set_languages("cxx17") add_defines(string.format("__XMAKE__=\"%s\"", os.scriptdir():gsub("\\", "/"))) add_files("learn/test.cpp") target("learn") set_kind("binary") - set_languages("cxx17") add_deps("test") add_files("learn/learn.cpp") target("summary") set_kind("binary") - set_languages("cxx17") add_deps("test") add_files("learn/summary.cpp")