Open vitacell opened 3 years ago
We need to teach the compiler about system-default include paths such as /usr/lib64/gcc/x86_64-slackware-linux/5.5.0/include
, which obviously depends on what distribution you are using. Currently, chibicc only supports Ubuntu 20.04 and other few Linux distributions. Slackware is not the one I support at the moment.
Can I fix this somehow? Is it trivial?
This is a function that defines the default include paths.
https://github.com/rui314/chibicc/blob/main/main.c#L53
You may try adding a few paths there to see your problem is solved.
Hi, it looks like adding adding either :
strarray_push(&include_paths, "/usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0/include");
or
strarray_push(&include_paths, "/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include");
Fixes the issue of chibicc not finding some header files; Now, for some reason, the compiler expect a ',' at places it shouldn't. I may be able to provide PR to add the include_paths above, if needed.
Hi, is there any fix to this "the compiler expected ;" I feel this is related to my error /stdarg.h:49: error: ';' expected (got "typedef")
I have same issue :
/usr/lib/gcc/x86_64-linux-gnu/9/include/stdarg.h:40: typedef __builtin_va_list __gnuc_va_list;
^ expected ','
chibicc helloworld.c -I/usr/lib/gcc/x86_64-linux-gnu/9/include
Hi. Including gcc header files is very likely not to work, as they seem to use a lot of GCC specific features. To make chibicc include the correct files, I had to:
include/
-directly from the build folder is added by referencing argv[0]
:
https://github.com/rui314/chibicc/blob/90d1f7f199cc55b13c7fdb5839d1409806633fdb/main.c#L56-I/usr/include/aarch64-linux-gnu
.Hi. Including gcc header files is very likely not to work, as they seem to use a lot of GCC specific features. To make chibicc include the correct files, I had to:
1. Make sure not to move the executable after it's been built. In the following line, the `include/`-directly from the build folder is added by referencing `argv[0]`: https://github.com/rui314/chibicc/blob/90d1f7f199cc55b13c7fdb5839d1409806633fdb/main.c#L56 2. Potentially include a different triple-specific header folder. Since I am cross compiling from ARM, I had to add the following include flag: `-I/usr/include/aarch64-linux-gnu`.
Hi, sorry I am not an expert. So I see that this line argument (or similar), do I need to add it into the "Makefile"?
CFLAGS=-std=c11 -g -fno-common -Wall -Wno-switch -I/usr/include/aarch64-linux-gnu
This?
Hi, sorry I am not an expert. So I see that this line argument (or similar), do I need to add it into the "Makefile"?
No, this is an option you add to chibicc
when running it, like so:
/path/to/installation/chibicc/chibicc -I/usr/include/aarch64-linux-gnu code.c
Hi. Including gcc header files is very likely not to work, as they seem to use a lot of GCC specific features. To make chibicc include the correct files, I had to:
- Make sure not to move the executable after it's been built. In the following line, the
include/
-directly from the build folder is added by referencingargv[0]
: https://github.com/rui314/chibicc/blob/90d1f7f199cc55b13c7fdb5839d1409806633fdb/main.c#L56- Potentially include a different triple-specific header folder. Since I am cross compiling from ARM, I had to add the following include flag:
-I/usr/include/aarch64-linux-gnu
.
I would be glad to try and see if your code works on my amd64 machine
Hi, sorry I am not an expert. So I see that this line argument (or similar), do I need to add it into the "Makefile"?
No, this is an option you add to
chibicc
when running it, like so:/path/to/installation/chibicc/chibicc -I/usr/include/aarch64-linux-gnu code.c
Huh ok. At the moment, I can't even to compile it.
chibicc helloworld.c -I/usr/lib/gcc/x86_64-linux-gnu/9/include
I encountered the same error
I get error: ';' expected (got "__gnuc_va_list")
error too with tcc, and I just found this page in duckduckgo somehow, I guess I'm gonna use gcc temporary
bash-4.3$ ./chibicc -o hello-world hello-world.c /usr/include/stdio.h:33: # include
^ stddef.h: cannot open file: No such file or directory
bash-4.3$ gcc --print-file-name=include /usr/lib64/gcc/x86_64-slackware-linux/5.5.0/include
When I copied stddef.h from /usr/lib64/gcc/x86_64-slackware-linux/5.5.0/include to /usr/include/ I get this message: bash-4.3$ ./chibicc -o hello-world hello-world.c /usr/include/libio.h:49: #include
^ stdarg.h: cannot open file: No such file or directory
When I copied stdarg.h from /usr/lib64/gcc/x86_64-slackware-linux/5.5.0/include to /usr/include/ I get this message: bash-4.3$ ./chibicc -o hello-world hello-world.c /usr/include/stdarg.h:40: typedef builtin_va_list gnuc_va_list; ^ expected ','
Maybe it might help, here is my problem with TCC too: bash-4.3$ ./tcc -o hello-world hello-world.c In file included from hello-world.c:1: In file included from /usr/include/stdio.h:74: In file included from /usr/include/libio.h:49: /usr/include/stdarg.h:40: error: ';' expected (got "__gnuc_va_list")