Closed HclX closed 2 months ago
Thanks @HclX for this report. Looks like the compiler flag parsing logic needs to be fixed.
-include
and not --include
what we handle. But double checked the GCC manual, and it mentions the include with a single dash prefix.)
Describe the bug A clear and concise description of what the bug is. Both clang and gcc support "--include" to include a header file when compiling a C files. It seems the right format should be either "--include=" or "--include" according to man page, but separated by space also works in practice. However, when separated by space, bear doesn't generate correct result database.
To Reproduce Steps to reproduce the behavior:
Here are the test files:
Running command
bear -- clang --includebar.h -c foo.c -o foo.o
orbear -- clang --include=bar.h -c foo.c -o foo.o
will generate expected database.However,
bear -- clang --include bar.h -c foo.c -o foo.o
will not:All three commands build fine when not using bear.
Expected behavior I'd expect bear generates same, correct json file when using "--include" just like the other two ways.
Environment:
Additional context
I'm using both clang and gcc and the behavior is same. Here are the clang/gcc versions I'm using:
~/Source/test$ clang --version Debian clang version 16.0.6 (19) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
~/Source/test$ gcc --version gcc (Debian 13.2.0-10) 13.2.0