I try to compile the following simple c++ file(a.cpp) with gcc-4.9.
#include <iostream>
#include <foo>
using namespace std;
int main()
{
int x = 3;
cout << f(x) << endl;
return 0;
}
"foo" is also the following simple c++ file (remove include guard to make code more simple).
int f(int ret){
return ret + 1;
}
I cannot compile a.cpp with gcc-4.9 because the compiler say:
a.cpp:2:15: fatal error: foo: No such file or directory
I think the compile error is caused because the user defined file is included as standard header file (put parentheses around, "<***>").
Before, I see the same error and know two methods to solve these compile errors.
First one is changing compiler gcc-4.9 to gcc-5.0.
Second one is replacing
#include <foo>
with
#include "foo"
.
Although I don't know why compile error is solved by theses methods, I do it since now.
But now, I see a code that cannot be solved by a second method. It includes many user defined file as standard file in many header file. So, by second method, we must edit the many header files.
Also it is solved by first method, but I wan to compile with gcc-4.9 now. I think If there exists a method to compile "a.cpp" by gcc-4.9 without editing, the codes can be compiled by the same method.
How can I compile "a.cpp" by gcc-4.9 without editing. And why I can compile "a.cpp" by gcc-5.0?