-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
blink/checked.h: fix syntax error when building with GCC 9.4 #150
Conversation
tkchia
commented
Aug 9, 2023
``` blink/checked.h:10:47: error: missing binary operator before token "(" 10 | (defined(__has_builtin) && (__has_builtin(__builtin_add_overflow) && \ | ^ ```
Unfortunately it seems we simply cannot try to test for So it is necessary to split the relevant part into two directives, like so:
I am guessing that Thank you! |
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.
Hello @tkchia,
Well, the good news is that this all gets to live in a header file :)
Out of curiosity, how likely might it be that gcc or clang might have __builtin_mul_overflow
but not __builtin_add_overflow
? I'm wondering whether we're ultimately just dealing with gcc and clang version numbers or other compilers as well these days?
Thank you!
Hello @ghaerr, I am not sure, but I think it is generally a good idea for code to test directly for features they want, whenever possible, in contrast to testing version numbers. 🙂 Incidentally, the relevant C23 proposal (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2669.pdf) does mention that Microsoft Visual C has an Thank you! |
Hello @tkchia,
I only ask that because, in the lines immediately before the Thanks for the information on the safe integer proposal in C23. Thank you! |
Hello @ghaerr, My suspicion is that the test for At the same time I guess there might be (who knows?) compilers that somehow manage to support Thank you! |