Giter Site home page Giter Site logo

Comments (4)

eliben avatar eliben commented on September 28, 2024

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.

mei-g avatar mei-g commented on September 28, 2024

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.

eliben avatar eliben commented on September 28, 2024

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.

mei-g avatar mei-g commented on September 28, 2024

okay, got it. Thanks very much!

from pycparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.