-
Notifications
You must be signed in to change notification settings - Fork 194
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 feature detection macro MP_HAS (2) #262
Conversation
933a50c
to
c91cb35
Compare
@sjaeckel What do we have to check here to make sure that this change does not break any things? I don't think it does, but what do you guys need to be convinced 😉 If you are worried about dead code elim, try this with /* dead.c */
#include <stdio.h>
void does_not_exist(void);
int main(void) {
if (sizeof("") == 1) {
puts("We're ok");
}
if (sizeof("X") == 1) {
does_not_exist();
}
return 0;
} |
565a7e2
to
1899041
Compare
In contrast to the solution in #214, this works on MSVC 2015 and 2017 as I just tested using appveyor. |
@karel-m can you please have a look if this works for your cases as well? |
This is what I call "a typo", nothing to complain about. Thank you for the fix. |
Obviously. What I wanted to say is that nobody tried any compiler that hits |
@sjaeckel Ping. See also https://www.gnu.org/prep/standards/standards.html#Conditional-Compilation where c conditionals are recommended for conditional compilation. |
6987dba
to
2a9148e
Compare
e51542e
to
efbabc1
Compare
@sjaeckel What is your opinion about this PR now? |
I'm not sure where the culprit has to be searched there... in the compiler providers who mostly try to mimic gcc or the ones who don't mimic gcc not being available easily... Which compilers did we test this now with?
Something missing? If this works with all those compilers I think it's safe to merge. |
ab4cfb4
to
046848c
Compare
@sjaeckel yes, the compilers you listed are the ones we tested so far. |
046848c
to
672242b
Compare
@sjaeckel I rebased this PR again on develop. CI all green. |
Ping @sjaeckel. Could you merge this PR or are there things to do? |
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 still don't really like those complex if-elseif statements/chain e.g. in mp_mul()
but I could live with it...
@czurnieden anything to add?
To Otherwise: no problems, can tick it off, too. |
@czurnieden Thanks!
Yes, it might be possible to improve this. In order to not introduce any unwanted changes, I took the most direct translation from the intermingled #if and if branches. |
@sjaeckel ping? |
See #214. I wanted to try again if I can make this work without using variadic macros, this time only relying on C89.
@karel-m Could you please try again your compiler suite?
@sjaeckel @czurnieden This PR is simpler and better than the one before. Hopefully it also works on older compilers. This helps to clean up control flow. Another advantage is that the compiler will check all branches. Dead code elimination will make sure that the dead branches are not compiled.