inducer / inducer/pycparserext
__extension__ before a typedef not working
- Dominant language
- Python
- Stars
- 91
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
When trying to parse and rewrite this source code (which compiles using `gcc basic_exemple.c`
```c
#include
__extension__ typedef unsigned long long uint64_t;
int main(){
uint64_t my_number = 42;
printf("Here's my numner %llu\n", my_number);
return 0;
}
```
using the following python script
```python
from pycparser import c_ast
from pycparserext import ext_c_parser
from pycparserext.ext_c_generator import GnuCGenerator
parser = ext_c_parser.GnuCParser()
with open('basic_exemple.pp', "r") as pf:
src = pf.read()
original_ast = parser.parse(src)
print(original_ast)
out_c = 'out.c'
with open(out_c, 'w') as newFile:
for line in GnuCGenerator().visit(original_ast).splitlines():
if "asm" in line:
newFile.write(line + ";\n")
else:
newFile.write(line + "\n")
```
it seems that the `__extension__` keyword rewritten correctly and the result in `out_c` is `typedef __extension__ unsigned long long uint64_t`. (the `.pp` file was generated using `gcc -E basic_exemple -o basic_exemple.pp`)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.