-
Notifications
You must be signed in to change notification settings - Fork 596
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 support for empty struct (#66) #254
Conversation
pycparser/c_parser.py
Outdated
# Empty structs are not pure-C99, but accepted. | ||
p[0] = klass( | ||
name=p[2], | ||
decls=[], |
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.
Worth mentioning in a comment that a distinction is now made between None and []
for the decls
?
Thanks! Please fix the failures to proceed |
Fixed, and slightly simplified the grammar. |
pycparser/c_parser.py
Outdated
decls=p[3], | ||
coord=self._token_coord(p, 2)) | ||
if len(p) == 4: | ||
# None means no members |
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.
Seems like the code has changed, there's no None assignment now - is this comment still relevant?
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.
Still relevant, but not in this function.
Comment moved to p_struct_or_union_specifier_1
(which handles the None
case)
pycparser/c_generator.py
Outdated
body_function = self._generate_enum_body | ||
s = name + ' ' + (n.name or '') | ||
if members is not None: | ||
# None means no members |
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.
What does this comment refer to now, in the current revision of the code?
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.
Same thing as before.
None
still means that no curly-braces-enclosed members are present (handled byp_struct_or_union_specifier_1
in the parser.- Non-empty sequence means curly braces with members.
- Empty sequence means curly braces with no members.
Line 303 (translating None
to an empty tuple
) caused enums to always be suffixed with (possibly empty) curly braces.
Thanks! |
Support empty
struct
in parser and c generator.Though not allowed by C99, empty
struct
s can be found in android headers.(Look for
__bionic_zero_size_is_okay_t
in android code).Note:
Issue #66 was closed because the original poster found a workaround.
As @eliben welcomed pull requests in comments, #66 could be reopened/reclosed as fixed.