[Bug pch/57242] precompiled headers ignored unless the .gch and TU's are compiled with certain combinations of -g flag
scottbaldwin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri May 10 18:33:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57242
--- Comment #4 from etherice <scottbaldwin at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> This is by design as -g changes the information produced by the front-end
> and maybe even predefines too.
I created a simpler test to demonstrate the bug. Two files:
----------
pch.hpp
----------
#ifndef __PCH_HPP__
#define __PCH_HPP__
#pragma message "[ not using pre-compiled headers ]"
#include <iostream>
#endif
----------
test.cpp
----------
#include <pch.hpp>
int main() {
std::cout << "hello world" << std::endl;
return 0;
}
----------
If you run commands [1] and [2] below, you will notice that pch is ignored.
[1] g++ -I. pch.hpp -o pch.hpp.gch
[2] g++ -I. -c test.cpp -o test.o
[3] g++ -I. -c test.cpp -o test.o -include pch.hpp
However, if you add -g3 to commands [1] and [2], then pch will be used in
command [2]. More specifically, you must use a combination of the -g flags I
described in the report for pch to be utilized.
One more note: Using the -include option (even though it's unnecessary in this
case) makes the -g3 flags no longer needed. To confirm this, execute commands
[1] and [3] and observe that pch is no longer ignored, even without the -g3
flags.
More information about the Gcc-bugs
mailing list