Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrosion tests should not test C++ features not used by Corrosion it… #184

Merged
merged 2 commits into from
May 20, 2022
Merged

Conversation

stephan57160
Copy link
Contributor

…self.

This PR follows discussion for #183.

  • Problem addressed with this PR:
  • CMakeLists.txt uses std_cxx_17 to compile it's test cases.
  • Tests cases need std_cxx_17, because of their use of <string_view>.
    Because of both, Corrosion fails to compile on 'old' systems (I did not say vintage :-)).
  • Investigations:
    As Corrosion does not use <string_view>, it's not needed to use this in its test cases.
    If <string_view> is not used anywhere, options std_cxx_17 are no more required.

  • Correction proposal:
    Use of std_cxx_14, instead of std_cxx_17.
    Remove the use of <string_view> in Corrosion test cases.
    Altogether, this allows older compilers to build Corrosion.

  • Remark:
    This PR keeps some std_cxx_14 (instead of _17) to keep the need of C++ Standard Library installed on the compilation host.
    I did not test, but I suppose std_cxx_11 would work too.

…self.

This PR follows discussion for #183.

* Problem addressed with this PR:
- CMakeLists.txt uses std_cxx_17 to compile it's test cases.
- Tests cases need std_cxx_17, because of their use of <string_view>.
Because of both, Corrosion fails to compile on 'old' systems (I did not say vintage :-)).

* Investigations:
As Corrosion does not use <string_view>, it's not needed to use this in its test cases.
If <string_view> is not used anywhere, options std_cxx_17 are no more required.

* Correction proposal:
Use of std_cxx_14, instead of std_cxx_17.
Remove the use of <string_view> in Corrosion test cases.
Altogether, this allows older compilers to build Corrosion.

* Remark:
This PR keeps some std_cxx_14 (instead of _17) to keep the need of C++ Standard Library installed on the compilation host.
I did not test, but I suppose std_cxx_11 would work too.
Copy link
Collaborator

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

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

Looks good. But we should probably still print the name coming from rust, even if not wrapped in a string_view.


extern "C" void cpp_function(char const *name) {
std::string_view const name_sv = name;
std::cout << "Hello, " << name_sv << "! I'm C++!\n";
std::cout << "Hello, " << "my name is lib.cpp" << "! I'm C++!\n";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
std::cout << "Hello, " << "my name is lib.cpp" << "! I'm C++!\n";
std::cout << "Hello, " << name << "! I'm C++!\n";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops :-)
I'll change that. Sorry.

What do you prefer ?
A 2nd commit or a squash ?

@ogoffart ogoffart merged commit b0f3977 into corrosion-rs:master May 20, 2022
@ogoffart
Copy link
Collaborator

Thanks for the PR

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.

2 participants