@@ -73,31 +73,20 @@ namespace xcpp
7373 xeus::register_interpreter (this );
7474 }
7575
76- static std::string get_stdopt ()
76+ static std::string get_stdopt (int argc, const char * const * argv )
7777 {
78- // We need to find what's the C++ version the interpreter runs with.
79- const char * code = R"(
80- int __get_cxx_version () {
81- #if __cplusplus > 202302L
82- return 26;
83- #elif __cplusplus > 202002L
84- return 23;
85- #elif __cplusplus > 201703L
86- return 20;
87- #elif __cplusplus > 201402L
88- return 17;
89- #elif __cplusplus > 201103L || (defined(_WIN32) && _MSC_VER >= 1900)
90- return 14;
91- #elif __cplusplus >= 201103L
92- return 11;
93- #else
94- return 0;
95- #endif
96- }
97- __get_cxx_version ()
98- )" ;
99- auto cxx_version = Cpp::Evaluate (code);
100- return std::to_string (cxx_version);
78+ std::string res = " 14" ;
79+ for (int i = 0 ; i < argc; ++i)
80+ {
81+ std::string arg (argv[i]);
82+ auto pos = arg.find (" -std=c++" );
83+ if (pos != std::string::npos)
84+ {
85+ res = arg.substr (pos + 8 );
86+ break ;
87+ }
88+ }
89+ return res;
10190 }
10291
10392 interpreter::interpreter (int argc, const char * const * argv) :
@@ -109,7 +98,7 @@ __get_cxx_version ()
10998 {
11099 // NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic)
111100 createInterpreter (Args (argv ? argv + 1 : argv, argv + argc));
112- m_version = get_stdopt ();
101+ m_version = get_stdopt (argc, argv );
113102 redirect_output ();
114103 init_preamble ();
115104 init_magic ();
0 commit comments