$ cat > foobar.h << EOF enum Foo { BAR }; #define BAR(x) #define BARBAR BAR EOF $ cat > main.cc << EOF #include "foobar.h" void func() { (void)BARBAR; aaa; } EOF $ g++ -c main.cc main.cc: In function 'void func()': main.cc:8:3: error: 'aaa' was not declared in this scope $ ccache g++ -c main.cc foobar.h: In function 'void func()': foobar.h:8:3: error: 'aaa' was not declared in this scope Please notice the wrong filename when using ccache. ccache 3.1.4 gcc 4.5.2
This seems to be a regression in GCC 4.5: % /usr/bin/g++-4.4 -E main.cc >main.ii % /usr/bin/g++-4.4 -c main.ii main.cc: In function ‘void func()’: main.cc:8: error: ‘aaa’ was not declared in this scope % /usr/bin/g++-4.5 -E main.cc >main.ii % /usr/bin/g++-4.5 -c main.ii foobar.h: In function ‘void func()’: foobar.h:8:3: error: ‘aaa’ was not declared in this scope This will be next to impossible to fix in ccache. Workaround: Set the CCACHE_CPP2 variable.
Thanks for your analysis. I've filed http://gcc.gnu.org/PR48248