eliben / pycparser

:snake: Complete C99 parser in pure Python
Other
3.24k stars 609 forks source link

Support for __attribute__((weak)) #510

Closed GregIthaca closed 1 year ago

GregIthaca commented 1 year ago

I searched the repository for the word 'weak' and the only place I can see it mentioned in in a few issues. It seems to me that this attribute could probably be parsed and stored as part of the funcspec or storage class specifier of FuncDef, since those are already represented as lists.

I'm not actually sure what syntactic category the weak attribute is normally included in; most the the references for both function specifiers and storage class specifiers ignore it, and it does technically apply to both functions and global variables, though I can't remember ever seeing the later utilized.

eliben commented 1 year ago

pycparser will not support __attribute__ since it's not standard C. You can define them away with the preprocessor (e.g. -D'__attribute__(x)=') which will make the code parse-able.