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

[msvc] changes to make library compatible with msvc compiler (194) #607

Merged
merged 48 commits into from
Sep 10, 2024

Conversation

czjhoppe
Copy link
Contributor

@czjhoppe czjhoppe commented Sep 3, 2024

This PR enables the use of this library with the MSVC compiler in version 194. To prevent the code in the example and test folders from becoming ugly, the scope of this PR is limited to the library part. To compile tests or examples with MSVC, please refer to the following links: https://github.com/czjhoppe/mp-units/tree/master-msvc-194 or https://github.com/czjhoppe/mp-units/tree/2.2-msvc-194.

Changes:

  • Added MSVC version 194 to compatible compiler in conanfile.py.
  • Removed some unreachable code in fmt.h to silence the warning in one case.
  • Added MP_UNITS_IS_CONST_EXPR which can be used in cases where MSVC encounters a parser error and expects an expression.
  • Added MP_UNITS_IS_VALUE which can be used in cases where MSVC prefers the type instead of the value for non-type template parameters.
  • Added MP_UNITS_IS_CONST_EXPR which can be used in cases where MSVC does not recognize that the underlying code is a constant expression.
  • Changed some short names because they hide a global identifier for MSVC.

Additional explanations:

  • sudo_cast.h: MSVC has problems with requires { typename std::common_type_t<T, Other>; } in cases with no common type.
    format.h: The iterator for string_view is not castable to char*.
    -quantity.h: operator*= behaves differently for runtime and compile time.
  • quantity_point.h: Some weird problem with PO.
  • ostream.h: the requires requires clause causes an internal compiler error for msvc

the type and not the value. (Issue reported)
…o a const. (caused by read of variable outside its lifetime)
src/core/include/mp-units/bits/fmt.h Outdated Show resolved Hide resolved
src/core/include/mp-units/bits/hacks.h Outdated Show resolved Hide resolved
src/core/include/mp-units/bits/hacks.h Outdated Show resolved Hide resolved
src/core/include/mp-units/bits/sudo_cast.h Show resolved Hide resolved
src/core/include/mp-units/format.h Show resolved Hide resolved
src/core/include/mp-units/framework/quantity_spec.h Outdated Show resolved Hide resolved
src/core/include/mp-units/framework/quantity_spec.h Outdated Show resolved Hide resolved
src/core/include/mp-units/framework/unit.h Outdated Show resolved Hide resolved
src/core/include/mp-units/ostream.h Outdated Show resolved Hide resolved
test_package/test_package.cpp Outdated Show resolved Hide resolved
src/core/include/mp-units/framework/quantity_spec.h Outdated Show resolved Hide resolved
src/core/include/mp-units/framework/quantity_spec.h Outdated Show resolved Hide resolved
src/core/include/mp-units/framework/unit.h Outdated Show resolved Hide resolved
mpusz
mpusz previously approved these changes Sep 10, 2024
Copy link
Owner

@mpusz mpusz left a comment

Choose a reason for hiding this comment

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

Awesome!!! This is a huge work! Thank you!

@czjhoppe
Copy link
Contributor Author

There is one last unresolved conversation.

@mpusz
Copy link
Owner

mpusz commented Sep 10, 2024

Yes, I know. I want to leave it and check by myself after merge 😉

@mpusz mpusz merged commit 39d735f into mpusz:master Sep 10, 2024
299 checks passed
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