@@ -101,33 +101,102 @@ namespace xcpp
101101 xeus::register_interpreter (this );
102102 }
103103
104+ // FIXME: This function should be upstreamed to CppInterOp. See
105+ // https://github.com/compiler-research/CppInterOp/issues/879
104106 static std::string get_stdopt ()
105107 {
106- // We need to find what's the C++ version the interpreter runs with.
107- const char * code = R"(
108- int __get_cxx_version () {
109- #if __cplusplus > 202302L
110- return 26;
111- #elif __cplusplus > 202002L
112- return 23;
113- #elif __cplusplus > 201703L
114- return 20;
115- #elif __cplusplus > 201402L
116- return 17;
117- #elif __cplusplus > 201103L || (defined(_WIN32) && _MSC_VER >= 1900)
118- return 14;
119- #elif __cplusplus >= 201103L
120- return 11;
121- #else
122- return 0;
123- #endif
124- }
125- __get_cxx_version ()
126- )" ;
127- auto cxx_version = Cpp::Evaluate (code);
128- return std::to_string (cxx_version);
129- }
108+ switch (Cpp::GetLanguageStandard (nullptr ))
109+ {
110+ case Cpp::InterpreterLanguageStandard::c89:
111+ return " c89" ;
112+ case Cpp::InterpreterLanguageStandard::c94:
113+ return " c94" ;
114+ case Cpp::InterpreterLanguageStandard::gnu89:
115+ return " gnu89" ;
116+ case Cpp::InterpreterLanguageStandard::c99:
117+ return " c99" ;
118+ case Cpp::InterpreterLanguageStandard::gnu99:
119+ return " gnu99" ;
120+ case Cpp::InterpreterLanguageStandard::c11:
121+ return " c11" ;
122+ case Cpp::InterpreterLanguageStandard::gnu11:
123+ return " gnu11" ;
124+ case Cpp::InterpreterLanguageStandard::c17:
125+ return " c17" ;
126+ case Cpp::InterpreterLanguageStandard::gnu17:
127+ return " gnu17" ;
128+ case Cpp::InterpreterLanguageStandard::c23:
129+ return " c23" ;
130+ case Cpp::InterpreterLanguageStandard::gnu23:
131+ return " gnu23" ;
132+ case Cpp::InterpreterLanguageStandard::c2y:
133+ return " c2y" ;
134+ case Cpp::InterpreterLanguageStandard::gnu2y:
135+ return " gnu2y" ;
136+ case Cpp::InterpreterLanguageStandard::cxx98:
137+ return " cxx98" ;
138+ case Cpp::InterpreterLanguageStandard::gnucxx98:
139+ return " gnucxx98" ;
140+ case Cpp::InterpreterLanguageStandard::cxx11:
141+ return " cxx11" ;
142+ case Cpp::InterpreterLanguageStandard::gnucxx11:
143+ return " gnucxx11" ;
144+ case Cpp::InterpreterLanguageStandard::cxx14:
145+ return " cxx14" ;
146+ case Cpp::InterpreterLanguageStandard::gnucxx14:
147+ return " gnucxx14" ;
148+ case Cpp::InterpreterLanguageStandard::cxx17:
149+ return " cxx17" ;
150+ case Cpp::InterpreterLanguageStandard::gnucxx17:
151+ return " gnucxx17" ;
152+ case Cpp::InterpreterLanguageStandard::cxx20:
153+ return " cxx20" ;
154+ case Cpp::InterpreterLanguageStandard::gnucxx20:
155+ return " gnucxx20" ;
156+ case Cpp::InterpreterLanguageStandard::cxx23:
157+ return " cxx23" ;
158+ case Cpp::InterpreterLanguageStandard::gnucxx23:
159+ return " gnucxx23" ;
160+ case Cpp::InterpreterLanguageStandard::cxx26:
161+ return " cxx26" ;
162+ case Cpp::InterpreterLanguageStandard::gnucxx26:
163+ return " gnucxx26" ;
164+ case Cpp::InterpreterLanguageStandard::opencl10:
165+ return " opencl10" ;
166+ case Cpp::InterpreterLanguageStandard::opencl11:
167+ return " opencl11" ;
168+ case Cpp::InterpreterLanguageStandard::opencl12:
169+ return " opencl12" ;
170+ case Cpp::InterpreterLanguageStandard::opencl20:
171+ return " opencl20" ;
172+ case Cpp::InterpreterLanguageStandard::opencl30:
173+ return " opencl30" ;
174+ case Cpp::InterpreterLanguageStandard::openclcpp10:
175+ return " openclcpp10" ;
176+ case Cpp::InterpreterLanguageStandard::openclcpp2021:
177+ return " openclcpp2021" ;
178+ case Cpp::InterpreterLanguageStandard::hlsl:
179+ return " hlsl" ;
180+ case Cpp::InterpreterLanguageStandard::hlsl2015:
181+ return " hlsl2015" ;
182+ case Cpp::InterpreterLanguageStandard::hlsl2016:
183+ return " hlsl2016" ;
184+ case Cpp::InterpreterLanguageStandard::hlsl2017:
185+ return " hlsl2017" ;
186+ case Cpp::InterpreterLanguageStandard::hlsl2018:
187+ return " hlsl2018" ;
188+ case Cpp::InterpreterLanguageStandard::hlsl2021:
189+ return " hlsl2021" ;
190+ case Cpp::InterpreterLanguageStandard::hlsl202x:
191+ return " hlsl202x" ;
192+ case Cpp::InterpreterLanguageStandard::hlsl202y:
193+ return " hlsl202y" ;
194+ case Cpp::InterpreterLanguageStandard::lang_unspecified:
195+ return " lang_unspecified" ;
196+ }
130197
198+ return " unknown" ;
199+ }
131200 interpreter::interpreter (int argc, const char * const * argv) :
132201 xmagics ()
133202 , p_cout_strbuf(nullptr )
0 commit comments