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

Support presence of __attribute__ in function declarations #21

Open
gmills-qti opened this issue Jan 12, 2016 · 2 comments
Open

Support presence of __attribute__ in function declarations #21

gmills-qti opened this issue Jan 12, 2016 · 2 comments

Comments

@gmills-qti
Copy link

I have a function declared like so that is not getting detected.

int foo(char *bar) __attribute__((nonnull(1)));

I played with the c_parser.py (0.1.2 from pypi) and got this to work. I ported to tip from github.

--- c_parser.py Tue Jan 12 11:33:20 2016
+++ c_parser.py.modd    Tue Jan 12 11:43:45 2016
@@ -1177,7 +1177,9 @@
         self.function_decl = (storage_class_spec +
                               self.type_spec('type') +
                               self.declarator('decl') +
-                              nestedExpr('{', '}').suppress())
+                              Optional(nestedExpr('{', '}').suppress()) +
+                              Optional(Literal('__attribute__').suppress() +
+                              nestedExpr('(', ')').suppress()))
         self.function_decl.setParseAction(self.process_function)

         # Struct definition

If there is another way to do this with extra_modifiers, let me know.

@gmills-qti
Copy link
Author

Nevermind. Figured it out.

CParser(..., replace={r'__attribute__.*;' : ';'}, ...)

@MatthieuDartiailh
Copy link
Owner

I will try to see if we can add a permanent fix. Thanks for reporting.

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

No branches or pull requests

2 participants