@@ -75,33 +75,38 @@ namespace xcpp
7575 xeus::register_interpreter (this );
7676 }
7777
78+ // FIXME: This function should be upstreamed to CppInterOp. See
79+ // https://github.com/compiler-research/CppInterOp/issues/879
7880 static std::string get_stdopt ()
7981 {
80- // We need to find what's the C++ version the interpreter runs with.
81- const char * code = R"(
82- int __get_cxx_version () {
83- #if __cplusplus > 202302L
84- return 26;
85- #elif __cplusplus > 202002L
86- return 23;
87- #elif __cplusplus > 201703L
88- return 20;
89- #elif __cplusplus > 201402L
90- return 17;
91- #elif __cplusplus > 201103L || (defined(_WIN32) && _MSC_VER >= 1900)
92- return 14;
93- #elif __cplusplus >= 201103L
94- return 11;
95- #else
96- return 0;
97- #endif
98- }
99- __get_cxx_version ()
100- )" ;
101- auto cxx_version = Cpp::Evaluate (code);
102- return std::to_string (cxx_version);
103- }
82+ switch (Cpp::GetLanguageStandard (nullptr ))
83+ {
84+ case Cpp::InterpreterLanguageStandard::c11:
85+ return " c11" ;
86+ case Cpp::InterpreterLanguageStandard::c17:
87+ return " c17" ;
88+ case Cpp::InterpreterLanguageStandard::c23:
89+ return " c23" ;
90+ case Cpp::InterpreterLanguageStandard::c2y:
91+ return " c2y" ;
92+ case Cpp::InterpreterLanguageStandard::cxx11:
93+ return " cxx11" ;
94+ case Cpp::InterpreterLanguageStandard::cxx14:
95+ return " cxx14" ;
96+ case Cpp::InterpreterLanguageStandard::cxx17:
97+ return " cxx17" ;
98+ case Cpp::InterpreterLanguageStandard::cxx20:
99+ return " cxx20" ;
100+ case Cpp::InterpreterLanguageStandard::cxx23:
101+ return " cxx23" ;
102+ case Cpp::InterpreterLanguageStandard::cxx26:
103+ return " cxx26" ;
104+ case Cpp::InterpreterLanguageStandard::lang_unspecified:
105+ return " lang_unspecified" ;
106+ }
104107
108+ return " unknown" ;
109+ }
105110 interpreter::interpreter (int argc, const char * const * argv) :
106111 xmagics ()
107112 , p_cout_strbuf(nullptr )
0 commit comments