-
Couldn't load subscription status.
- Fork 36
Remove whitespace in literal operator declarations #334
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
Conversation
Fixes this warning from clang:
```
In file included from D:/src/test.cpp:6:
D:/src/intx/include/intx/intx.hpp:1622:1: warning: identifier '_u128' preceded by whitespace in a literal operator declaration is deprecated [-Wdeprecated-literal-operator]
1622 | DEFINE_ALIAS_AND_LITERAL(128);
| ^
D:/src/intx/include/intx/intx.hpp:1617:34: note: expanded from macro 'DEFINE_ALIAS_AND_LITERAL'
1617 | consteval uint##N operator"" _u##N(const char* s) \
| ^
<scratch space>:168:1: note: expanded from here
168 | _u128
```
f7d3446 to
66a5720
Compare
|
fyi, pr for a similar fix for msvc's new preoprocessor in boost::mp boostorg/multiprecision#667 |
include/intx/intx.hpp
Outdated
| } | ||
|
|
||
| #define INTX_JOIN2(X, Y) X##Y | ||
| #define INTX_JOIN1(X, Y) INTX_JOIN2(X, Y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need two levels of these JOIN macros?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need two levels of these
JOINmacros?
I didn't make it that way because I was bored :) At first I took whatever was from boost, and their join is 3-step nowadays:
#define BOOST_JOIN(X, Y) BOOST_DO_JOIN(X, Y)
#define BOOST_DO_JOIN(X, Y) BOOST_DO_JOIN2(X,Y)
#define BOOST_DO_JOIN2(X, Y) X##Ywhatever I did, I couldn't make it with 1 or 2 defines. I was already convinced that there was no way to avoid the warning in the first place, but then figured out what makes msvc happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did a bit more tinkering, and just got rid of one join
include/intx/intx.hpp
Outdated
| using uint##N = uint<N>; \ | ||
| namespace literals \ | ||
| { \ | ||
| consteval uint##N INTX_LITERAL(N)(const char* s) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| consteval uint##N INTX_LITERAL(N)(const char* s) \ | |
| consteval uint##N INTX_JOIN(operator"", _u##N)(const char* s) \ |
will this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, works. pr updated
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, thanks very much for solving this issue.
|
Looking at this and trying to determine if my build is using the new commit or if it's building the older code in Hunter. On MacOS with clang seeing this error from DEFINE_ALIAS_AND_LITERAL(128): Documentation: https://clang.llvm.org/docs/UsersManual.html#controlling-implementation-limits |
|
I don't understand why the template instantiation hits this limit, but it apparently does when building with clang on MacOS. See: https://clang.llvm.org/docs/UsersManual.html#controlling-implementation-limits I added this to CMakeLists.txt and the build succeeded. Can't tell if this is newly-introduced behaviour with this commit, I am new here.
|
|
This is different issue. Quick fix is to change |



Fixes this warning from clang: