Skip to content

Fix compilation when building with msvc's new preprocessor #667

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

Merged
merged 1 commit into from
Mar 25, 2025

Conversation

pps83
Copy link
Contributor

@pps83 pps83 commented Mar 24, 2025

fixes the following error when standard conforming preprocessor is enabled (/Zc:preprocessor option)

1>time.cpp
1>D:\work-pps\boost_1_87_0\boost\multiprecision\cpp_int\literals.hpp(270,1): warning C5103: pasting '""_cppi' and '128' does not result in a valid preprocessing token
1>(compiling source file '../src/time.cpp')
1>    D:\work-pps\boost_1_87_0\boost\multiprecision\cpp_int\literals.hpp(252,9):
1>    in expansion of macro 'BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL'
1>    D:\work-pps\boost_1_87_0\boost\config\helper_macros.hpp(33,9):
1>    in expansion of macro 'BOOST_JOIN'
1>    D:\work-pps\boost_1_87_0\boost\config\helper_macros.hpp(34,9):
1>    in expansion of macro 'BOOST_DO_JOIN'
1>    D:\work-pps\boost_1_87_0\boost\config\helper_macros.hpp(35,9):
1>    in expansion of macro 'BOOST_DO_JOIN2'
1>D:\work-pps\boost_1_87_0\boost\multiprecision\cpp_int\literals.hpp(270,1): error C2988: unrecognizable template declaration/definition

@pps83
Copy link
Contributor Author

pps83 commented Mar 24, 2025

Perhaps, it's better to

#define BOOST_MP_LIT(P, N) BOOST_JOIN(operator"", BOOST_JOIN(P, N))

This way grepping for operator"" would work. Lmk if I should update the PR

@mborland
Copy link
Member

Perhaps, it's better to

#define BOOST_MP_LIT(P, N) BOOST_JOIN(operator"", BOOST_JOIN(P, N))

This way grepping for operator"" would work. Lmk if I should update the PR

I think this would be better

fixes the following error:
```
1>time.cpp
1>D:\work-pps\boost_1_87_0\boost\multiprecision\cpp_int\literals.hpp(270,1): warning C5103: pasting '""_cppi' and '128' does not result in a valid preprocessing token
1>(compiling source file '../src/time.cpp')
1>    D:\work-pps\boost_1_87_0\boost\multiprecision\cpp_int\literals.hpp(252,9):
1>    in expansion of macro 'BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL'
1>    D:\work-pps\boost_1_87_0\boost\config\helper_macros.hpp(33,9):
1>    in expansion of macro 'BOOST_JOIN'
1>    D:\work-pps\boost_1_87_0\boost\config\helper_macros.hpp(34,9):
1>    in expansion of macro 'BOOST_DO_JOIN'
1>    D:\work-pps\boost_1_87_0\boost\config\helper_macros.hpp(35,9):
1>    in expansion of macro 'BOOST_DO_JOIN2'
1>D:\work-pps\boost_1_87_0\boost\multiprecision\cpp_int\literals.hpp(270,1): error C2988: unrecognizable template declaration/definition
```
@pps83
Copy link
Contributor Author

pps83 commented Mar 24, 2025

...
This way grepping for operator"" would work. Lmk if I should update the PR

applied. This way it's better

@mborland
Copy link
Member

...
This way grepping for operator"" would work. Lmk if I should update the PR

applied. This way it's better

Thanks. I approved the CI run

Copy link

codecov bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.1%. Comparing base (7fac807) to head (d927981).
Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop    #667   +/-   ##
=======================================
  Coverage     94.1%   94.1%           
=======================================
  Files          279     279           
  Lines        28979   28979           
=======================================
  Hits         27253   27253           
  Misses        1726    1726           
Files with missing lines Coverage Δ
include/boost/multiprecision/cpp_int/literals.hpp 100.0% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7fac807...d927981. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jzmaddock
Copy link
Collaborator

How does this interact with #665 and #663 ?

@mborland
Copy link
Member

How does this interact with #665 and #663 ?

Good catch. I just checked out this commit and it does not cause "-Wdeprecated-literal-operator" to be emitted. I believe it's safe since that was the only intention of those two PRs.

@pps83
Copy link
Contributor Author

pps83 commented Mar 24, 2025

How does this interact with #665 and #663 ?

I also build with clang and had these warnings. After I took latest updates that fixed them I had issues with msvc. With this PR both issues should be resolved now.

@mborland mborland merged commit eef4acf into boostorg:develop Mar 25, 2025
79 checks passed
@pps83
Copy link
Contributor Author

pps83 commented Mar 25, 2025

I was about to ping... there is a less intrusive option also:
from:

operator BOOST_JOIN(""_cppi, Bits)

to:

BOOST_JOIN(operator ""_cppi, Bits)

even this one, as there were no reason to use BOOST_JOIN there:

operator ""_cppi##Bits 

@pps83
Copy link
Contributor Author

pps83 commented Mar 25, 2025

let me know if I should create a new pr and remove BOOST_MP_LIT thing completely

@mborland
Copy link
Member

I think it's fine. We can still grep for operator "" in the changes from this PR which we weren't able to do previously.

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.

3 participants