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
c99 fixes #2303
c99 fixes #2303
Conversation
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.
FWIW, I think this is not a good change. C99 is now more than 20 years old. Unless we're really targeting a compiler that doesn't support it (and we can't be because gumbo itself makes heavy use of C99 features), we should figure out how to pass -std=c99 to the compiler.
(If there were features of C11 that I thought were useful, I'd say we should use -std=c11, but there really aren't for this.)
That should have referred only to 3e3485b and not the PR as a whole. |
Does adding append_cflags("-std=c99") here not work? |
Hi Steve, thanks for bringing this up, and I'm sorry I didn't wait for your input before whacking the "merge" button. I almost entirely agree with you despite having introduced the change. But I will point out that @nobu has put effort into keeping the codebase of Ruby, Nokogiri, and other gems "clean" and removing C90-isms because (I think) Ruby 2.6 and earlier still use them, and I want to respect his wishes despite not fully understanding them. I've tagged Nobu here in case he has additional insight. My only hesitation about passing |
See #2304 |
What problem is this PR intended to solve?
#2302 reports a compilation failure on RHEL6, RHEL7, and SLES12. These are older distros (RHEL7 is running gcc 4.8) which seem to compile in a C90-ish mode by default that gives errors on C99-isms.
This PR removed the C99isms (which are errors) as well as some C90isms (which generate warnings). Specifically:
for
statement (C99-ism)This PR also cleans up some C casting related to how we're handling
const
qualifiers. Specifically:gumbo.c
is now using(const xmlChar *)
in place ofBAD_CAST
(which is an alias for(xmlChar *)
)(xmlChar *)(uintptr_t)ptr
into a macroDISCARD_CONST_QUAL
DISCARD_CONST_QUAL
in one additional place inxml_node.c
As a result, even when using
-Wcast-qual
on older Rubies that support it, we now see no compiler warnings.Have you included adequate test coverage?
I considered setting up CI using a comparable Centos docker image, but I didn't feel like there was much regression value to that test, given the nature of this failure. I could be argued into doing it, if anyone feels strongly.
Does this change affect the behavior of either the C or the Java implementations?
No functional changes.