Skip to content

[requires CppInterOp 1.9.0 release] Use Cpp::GetLanguageStandard to get language standard#461

Open
mcbarton wants to merge 1 commit intocompiler-research:mainfrom
mcbarton:detect-standard-via-c++
Open

[requires CppInterOp 1.9.0 release] Use Cpp::GetLanguageStandard to get language standard#461
mcbarton wants to merge 1 commit intocompiler-research:mainfrom
mcbarton:detect-standard-via-c++

Conversation

@mcbarton
Copy link
Copy Markdown
Collaborator

With CppInterOp 1.9.0, an API was created which can detect the c/c++ standard used (Cpp::GetLanguageStandard). This PR replaces get_stdopt xeus-cpp is currently using with Cpp::GetLanguageStandard. This PR needs testing and I will check it in the coming days.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 21. Check the log or trigger a new build to see more.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 10.22727% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.90%. Comparing base (88ae231) to head (31ff22e).

Files with missing lines Patch % Lines
src/xinterpreter.cpp 10.22% 79 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #461      +/-   ##
==========================================
- Coverage   80.56%   73.90%   -6.66%     
==========================================
  Files          21       21              
  Lines         854      939      +85     
  Branches       80       80              
==========================================
+ Hits          688      694       +6     
- Misses        166      245      +79     
Files with missing lines Coverage Δ
src/xinterpreter.cpp 60.49% <10.22%> (-28.75%) ⬇️
Files with missing lines Coverage Δ
src/xinterpreter.cpp 60.49% <10.22%> (-28.75%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment on lines +80 to +168
switch (Cpp::GetLanguageStandard(nullptr))
{
case Cpp::InterpreterLanguageStandard::c89:
return "c89";
case Cpp::InterpreterLanguageStandard::c94:
return "c94";
case Cpp::InterpreterLanguageStandard::gnu89:
return "gnu89";
case Cpp::InterpreterLanguageStandard::c99:
return "c99";
case Cpp::InterpreterLanguageStandard::gnu99:
return "gnu99";
case Cpp::InterpreterLanguageStandard::c11:
return "c11";
case Cpp::InterpreterLanguageStandard::gnu11:
return "gnu11";
case Cpp::InterpreterLanguageStandard::c17:
return "c17";
case Cpp::InterpreterLanguageStandard::gnu17:
return "gnu17";
case Cpp::InterpreterLanguageStandard::c23:
return "c23";
case Cpp::InterpreterLanguageStandard::gnu23:
return "gnu23";
case Cpp::InterpreterLanguageStandard::c2y:
return "c2y";
case Cpp::InterpreterLanguageStandard::gnu2y:
return "gnu2y";
case Cpp::InterpreterLanguageStandard::cxx98:
return "cxx98";
case Cpp::InterpreterLanguageStandard::gnucxx98:
return "gnucxx98";
case Cpp::InterpreterLanguageStandard::cxx11:
return "cxx11";
case Cpp::InterpreterLanguageStandard::gnucxx11:
return "gnucxx11";
case Cpp::InterpreterLanguageStandard::cxx14:
return "cxx14";
case Cpp::InterpreterLanguageStandard::gnucxx14:
return "gnucxx14";
case Cpp::InterpreterLanguageStandard::cxx17:
return "cxx17";
case Cpp::InterpreterLanguageStandard::gnucxx17:
return "gnucxx17";
case Cpp::InterpreterLanguageStandard::cxx20:
return "cxx20";
case Cpp::InterpreterLanguageStandard::gnucxx20:
return "gnucxx20";
case Cpp::InterpreterLanguageStandard::cxx23:
return "cxx23";
case Cpp::InterpreterLanguageStandard::gnucxx23:
return "gnucxx23";
case Cpp::InterpreterLanguageStandard::cxx26:
return "cxx26";
case Cpp::InterpreterLanguageStandard::gnucxx26:
return "gnucxx26";
case Cpp::InterpreterLanguageStandard::opencl10:
return "opencl10";
case Cpp::InterpreterLanguageStandard::opencl11:
return "opencl11";
case Cpp::InterpreterLanguageStandard::opencl12:
return "opencl12";
case Cpp::InterpreterLanguageStandard::opencl20:
return "opencl20";
case Cpp::InterpreterLanguageStandard::opencl30:
return "opencl30";
case Cpp::InterpreterLanguageStandard::openclcpp10:
return "openclcpp10";
case Cpp::InterpreterLanguageStandard::openclcpp2021:
return "openclcpp2021";
case Cpp::InterpreterLanguageStandard::hlsl:
return "hlsl";
case Cpp::InterpreterLanguageStandard::hlsl2015:
return "hlsl2015";
case Cpp::InterpreterLanguageStandard::hlsl2016:
return "hlsl2016";
case Cpp::InterpreterLanguageStandard::hlsl2017:
return "hlsl2017";
case Cpp::InterpreterLanguageStandard::hlsl2018:
return "hlsl2018";
case Cpp::InterpreterLanguageStandard::hlsl2021:
return "hlsl2021";
case Cpp::InterpreterLanguageStandard::hlsl202x:
return "hlsl202x";
case Cpp::InterpreterLanguageStandard::hlsl202y:
return "hlsl202y";
case Cpp::InterpreterLanguageStandard::lang_unspecified:
return "lang_unspecified";
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will need to move to cppinterop in a longer run...

Copy link
Copy Markdown
Collaborator Author

@mcbarton mcbarton Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for the next cppinterop release I will upstream this function. This PR is ready as of now, if your willing to approve and take it in.

I'm not sure what this will return for the openmp kernels. I suspect it will return the c/c++ standard.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be fine assuming we have a fixme explaining that and pointing to a bug report in cppinterop

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added fixme comment. Also did this for my PR about using CppInterOp to get the language (this PR #462)

Copy link
Copy Markdown
Collaborator

@anutosh491 anutosh491 Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arghh okay I'm not a fan of a huge switch case like this lying in xinterpreter.cpp !

Should be restricted to creating the interpreter and overriding the kernel methods from xeus.

Can this lie in a xutils/xhelper ? (we should have one I think)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also let's just start with the kernels we currently cater to ? I guess we don't need such a huge switch case.

Offcourse when shifting it to cppinterop we should have everything !

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reduced it so that get_stdopt covers all the c++ standards we did previously, plus all the c standards from c11 onwards, since we have the c kernels now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out I need to cover all cases otherwise I get these errors https://github.com/compiler-research/xeus-cpp/actions/runs/23733299499/job/69131805701?pr=461#step:11:33 , since we treat all warnings as errors in the ci. I will switch back.

@mcbarton mcbarton marked this pull request as ready for review March 27, 2026 16:54
@mcbarton mcbarton requested a review from vgvassilev March 27, 2026 16:54
@mcbarton mcbarton force-pushed the detect-standard-via-c++ branch 4 times, most recently from 51e79c3 to b545d00 Compare March 30, 2026 07:40
@mcbarton mcbarton requested a review from anutosh491 March 30, 2026 07:40
@mcbarton mcbarton force-pushed the detect-standard-via-c++ branch 3 times, most recently from 19e4ea1 to 9f90164 Compare March 30, 2026 09:49
@mcbarton mcbarton force-pushed the detect-standard-via-c++ branch from 9f90164 to 31ff22e Compare March 31, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_stdopt caters only to the c++ kernel Prefer extracting C++ standard version from argv at startup over runtime evaluation

4 participants