-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Remove declarations inside for loops #4140
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
b846771
to
94dfefb
Compare
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.
Have a small doubt here. Any particular reason behind making this change. Generally I think best practice is to use the smallest scope possible for variables.
This format is not supported in older version of C (before C99). |
Let's check just declarations in for loops. As for declaration before statements, it's better to avoid them, but it's not a strict requirement as if you compile with |
Got it. thanks |
I'd recommend not merging this patch. It's true that C89 didn't support declarations in Also, as mentioned in #4140 (comment), librdkafka already uses C99-isms in many places. If you took a time machine back to the '80s and tried to compile librdkafka with one of those compilers, you'd find that they complain about a lot more than just variable declarations — they'd complain about Basically, I think librdkafka should assume the use of a compiler about as old as Kafka itself (i.e. 2011), but going further back in time than that seems impractical and masochistic. |
@Quuxplusone this is not for being C89 compatible, we're following the project declaration:
But, limitation 1 has to be dropped because of #4140 (comment) That said, it seems we should move to standard C99 |
@emasab: "this is not for being C89 compatible, we're following the project declaration" — Except that, as you say, you're not following the description in the README. The description in the README describes a world that self-evidently is not our reality: #4140 (comment) . So it seems like what you should do, really, is just make the two-line update to the README's description so that it matches the real world. This PR makes reality worse, but (as you say) doesn't even succeed at implementing the dystopia described in the README. |
@Quuxplusone don't be upset, given my last comment I hoped it was clear that I'm checking if we can remove these statements in the README, and I've still not merged this for that reason. |
We need to merge this as we support RHEL/CentOS 7, whose EOL is in 2024. CentOS has a GCC version before 5.1.0 where the default was changed from gnu90. With these fixes it compiles correctly configuring with gnu90, and gives error without, so that's the minimum C "standard" we need to support. We're going to include this in the README and in the CI. Up to 2024 when CentOS 7 will reach EOL. |
No description provided.