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

Add method for specifying C/C++ standard version #761

Merged
merged 1 commit into from Aug 17, 2023

Conversation

hikari-no-yume
Copy link
Contributor

@hikari-no-yume hikari-no-yume commented Dec 5, 2022

As requested by #565.

Please have a look at the documentation I have included. :)

I am not doing any abstraction over special cases like the name for the work-in-progress standard version. It's just the basics.

I want to propose adding this to cc because:

  • It should be useful fairly often, considering that using the right standard version can be critical to compiling modern code. I have a C++17 dependency in one of my projects, and I couldn't build my code interfacing with it without specifying the standard version, because even very new compilers seem to default to older versions. As far as I know, the compatibility between C++ versions isn't perfect, so that might be why.
  • It can save people the effort of having to consult both GCC/Clang and MSVC documentation, and improve the portability of code from people who haven't tested on Windows:
    • The GCC/Clang and MSVC flag syntaxes are not quite the same, so without support in the cc crate, the developer has to write conditional, platform-specific code.
    • The common subset of supported versions between GCC/Clang and MSVC is not something you can intuitively guess. The documentation added here can help.
  • While I haven't done that here, it could be enhanced in future to handle special cases like the different names for the WIP future C and C++ standards.

src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

This looks fine to me.

@thomcc
Copy link
Member

thomcc commented Aug 16, 2023

There are conflicts I guess. Can you rebase?

@hikari-no-yume
Copy link
Contributor Author

Sure, I can do that later today.

Maybe I can take that opportunity to edit the doc comment a bit to address the review comment above.

@thomcc
Copy link
Member

thomcc commented Aug 16, 2023

Sure. I think it's fine as-is but additional clarification wouldn't hurt.

@hikari-no-yume
Copy link
Contributor Author

I rebased it now. The conflict was caused by the code being changed to use Arc<str> instead of String for all the other fields. I'm not sure whether that has any benefit for this field, but I changed it to match. I also clarified the thing with MSVC and C++11.

@thomcc
Copy link
Member

thomcc commented Aug 17, 2023

Thanks.

@thomcc thomcc merged commit 360754b into rust-lang:main Aug 17, 2023
16 checks passed
@hikari-no-yume
Copy link
Contributor Author

Thanks for taking the time to review and merge this! :)

@hikari-no-yume
Copy link
Contributor Author

@thomcc Oh, maybe you'll want to close #565 now.

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.

None yet

3 participants