Skip to content
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

change clang _Bool to more readable bool #77

Closed
wants to merge 1 commit into from

Conversation

ceepu
Copy link

@ceepu ceepu commented Jan 14, 2022

when declare with bool, clang auto change it to _Bool.

when declare with bool, clang auto change it to _Bool.
@ceepu ceepu closed this Jan 14, 2022
@ceepu ceepu deleted the patch-1 branch January 14, 2022 17:34
@ceepu ceepu restored the patch-1 branch January 14, 2022 17:44
@ceepu ceepu reopened this Jan 14, 2022
@jnikula
Copy link
Owner

jnikula commented Jan 15, 2022

Thanks for your contribution!

Looks like the root cause is that <stdbool.h> defines bool instead of typedeffing it. Only the preprocessor sees bool, and from the compiler's perspective, it's _Bool. Contrast with <stdint.h> which typedefs e.g. uint32_t.

The trouble with your fix is that it's very specific to this particular problem. What if the source code had _Bool? Are there other cases where we should use whatever is in the source (and what the preprocessor sees) instead of the underlying type? I.e. should we look at the tokenized input instead?

Finally, I should really finish my guide for contributing. For any changes like this, I expect a test update that ensures we don't break this in the future. It's also helpful in demonstrating the need for the change. Also, please write a meaningful commit message.

@@ -170,6 +170,8 @@ def _decl_fixup(ttype, name):

ttype, name = _function_pointer_fixup(ttype, name)

if ttype == '_Bool': ttype = 'bool'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's useful to follow the style we have for other fixups. One function per fixup, and the comments for the function can desribe what it's about.

@jnikula
Copy link
Owner

jnikula commented Oct 27, 2022

I opened #92 to track this, but I'm closing the merge request.

@jnikula jnikula closed this Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants