Comments (4)
I'm not sure this file was generated after preprocessing with the fake headers. I see no menion of "fake" in that file, and I'd expect to see many if indeed the fake headers were added with -I
to the preprocessing step.
Another piece of evidence is that the fake headers actually include fake typedefs for __builtin_va_list
and va_list
, so they should compile properly.
For example, if you run from the root directory of pycparser
:
$ gcc -E -I utils/fake_libc_include/ ./tests/c_files/year.c
You will see the preprocessing pull stuff from the fake headers, including va_list
which is used inside the C file. The output of this preprocessing should be successfully parsed by pycparser. You can see this in action by running the examples/using_cpp_libc.py
example.
from pycparser.
So sorry. Uploaded the wrong file. Here it is:
cpu_pp.log
the compiling commands is the following:
gcc -E -D'__attribute__(x)=' -nostdinc -I/home/user/pycparser/utils/fake_libc_include -I/home/user/kernel-source/arch/x86/include -I./arch/x86/include/generated -I/home/user/kernel-source/include -I./include -I/home/user/kernel-source/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/user/kernel-source/include/uapi -I./include/generated/uapi -include /home/user/kernel-source/include/linux/compiler-version.h -include /home/user/kernel-source/include/linux/kconfig.h -include /home/user/kernel-source/include/linux/compiler_types.h -D__KERNEL__ -m16 -g -Os -D_SETUP -I /home/user/kernel-source/arch/x86/boot -I./arch/x86/boot -o arch/x86/boot/cpu.o /home/user/kernel-source/arch/x86/boot/cpu.c
There were warnings of redefinition.
/home/user/pycparser/utils/fake_libc_include/_fake_defines.h:208: warning: "va_arg" redefined 208 | #define va_arg(_ap, _type) __builtin_va_arg((_ap)) | In file included from /home/user/kernel-source/arch/x86/boot/boot.h:21, from /home/user/kernel-source/arch/x86/boot/cpu.c:16: /home/user/kernel-source/include/linux/stdarg.h:8: note: this is the location of the previous definition 8 | #define va_arg(v, T) __builtin_va_arg(v, T)
However, the linux header includes have to be there. Otherwise it won't compile.
Any suggestions are really welcomed!
from pycparser.
You have to plow through the issues one by one. The Linux kernel is not - to the best of my knowledge - trying to be "standard C99", so it has some duplicate definitions and so on. You can move the __builtin_va_list
around, but the next problem that pops is that https://codebrowser.dev/linux/linux/include/linux/stddef.h.html#false defines an enum using true
and false
, which in C99 are defined to be 1 and 0 already.
If I had time to go through the whole exercise now, I would try to create a separate version of the fake headers fine-tuned for the linux kernel, and knock the problems out one by one. There could be more difficult issues ahead like specific GNU extensions used by the kernel code which pycparser does not support, though.
from pycparser.
okay, got it. Thanks very much!
from pycparser.
Related Issues (20)
- Missing ; when generating code for extern functions
- Can
- Can't parse incomplete types and other syntactically valid but non-compilable code HOT 1
- Curly braces inside braced-group throws ParseError HOT 2
- AssertionError
- Two-dimensional array binding type problem HOT 1
- Is there a release plan for the next version of pycparser?
- parser error with typedef HOT 10
- assertion error on gcc-9 stddef.h
- Is there a way to find the function declaration matching a function call? HOT 1
- CParser doesn't work with comments HOT 1
- Add end of token coord
- Unable to parse labels at end of block HOT 1
- BUG: pycparser treats empty declarations as a binary operation HOT 1
- TypeError:'Nonetype' object is not callable HOT 5
- "sorry, but this version only supports 100 named groups" HOT 1
- Parsing `va_arg(foo, type)` HOT 3
- Unable to parse through comments and can't support directives HOT 2
- Parser can't handle unknown data types for variables HOT 1
- Parser unbale to handle custom data types for custom functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycparser.