User defined include paths are pushed to the vector before
system include paths as we handle command line flags before
calling cpp_init. Iterating this vector in reverse order
prefers system headers to user headers, which is wrong.
A test case:
$ echo 'int main() {}' > stdio.h
$ echo '#include ' > test.c
$ ./8cc -I. -c test.c && gcc test.o
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference tomain'
collect2: error: ld returned 1 exit status
This partially reverts bcaf3b2648e but this was broken even
before the removal of vec_unshift, I think.
User defined include paths are pushed to the vector before system include paths as we handle command line flags before calling cpp_init. Iterating this vector in reverse order prefers system headers to user headers, which is wrong.
A test case:
$ echo 'int main() {}' > stdio.h $ echo '#include' > test.c
$ ./8cc -I. -c test.c && gcc test.o
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function
_start': (.text+0x20): undefined reference to
main' collect2: error: ld returned 1 exit statusThis partially reverts bcaf3b2648e but this was broken even before the removal of vec_unshift, I think.