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
Fixes to avoid multiple definitions for thread pools and suppress compiler warnings. #1
Conversation
include/ips4o/bucket_pointers.hpp
Outdated
using atomic_type = unsigned __int128; | ||
// __extension__ suppresses the pedantic warning about __int128 | ||
// not being ISO C++ compliant | ||
__extension__ using atomic_type = unsigned __int128; |
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.
Unless I'm mistaken, you can also use __uint128_t
to avoid the pedantic warning without having to use __extension__
.
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.
It seems that it does, and a quick Google suggests that it supported by at least Clang, GCC, and Intel's compiler. I don't know enough about compilers and support to say for certain that this is a safe replacement, but if it is then it might be preferable to __extension__
.
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.
I'm unfortunately no more knowledgeable, I just know that the use of __int128_t
and __uint128_t
is somewhat widespread and have the advantage of being "normal" from the language POV, just another type which happens to have compiler support.
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.
Thank you for your recommendation. However, I would prefer a cast to int, the type of log_buckets_.
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.
I would prefer to remove the unused function parameters.
I went through and adopted the suggestions:
|
When using the ips4o parallel sort via normal Makefiles, I ran into multiple definition errors when compiling associated with the various *ThreadPool Impl structs. I inlined all the associated functions where the definition was separated from the declaration, which resolved the errors. This is the first commit in the PR.
In addition, I attempted to suppress most of the (presumably spurious) compiler warnings when including the ips4o headers. (I did this for
-Wall -Wextra -Wpedantic
, but I typically don't use pedantic so I don't actually care about the warnings associated with__int128
.) The remaining warning, as far as I get them at least, is associated withclassifier.h:131
:I attempted to add parentheses and such to make this warning go away, but the compiler seems to be hung up on something here. I don't fully understand the control flow of this function, but if you can explain it to me or have some ideas regarding the warning, I would be happy to take another look at the warning and try and suppress it.
Thanks for your time and feedback!