Bug #6908 2006-03-28 21:50
jcayzac
Wrong parameter for gcc
I was wondering why the tutorials for libnoise didn't work for me, when I came across these lines in compilerMINGWgenerator.cpp: // for gcc-4.0+, use the following: // pch_prepend << _T("-iquote") << dir << _T(' '); // for earlier versions, -I- must be used pch_prepend << _T("-I- "); count = (int)includedDirs.GetCount(); What is the motivation behind this? According to gcc man: "In addition, the -I- option inhibits the use of the current directory (where the current input file came from) as the first search directory for #include "file". There is no way to override this effect of -I-. With -I. you can specify searching the directory which was current when the compiler was invoked. That is not exactly the same as what the preprocessor does by default, but it is often satisfactory." It simply break the following, commonly used, header scheme: #include <foo/bar.h> ... and in bar.h: #include "moo/moo.h" moo.h should be foo/moo/moo.h. But gcc can't find it because of -I-. So this could at least be an option left to the user.
- Category
- Compiler
- Group
- Status
- Closed
- Close date
- 2006-04-10 09:17
- Assigned to
History
Option added in compiler dialog to explicitely add the project's top-level path in the compiler's search path.
Bug is *NOT* fixed:
a) The characteristics of the "fix" are different: Instead of searching in the current files directory *first*, it is searched *last*! The include directive has to be in the first one.
b) Even if it is the first one, this helps only for direct includes. It wouldn't even fix the given example, because it would add the current files directory to the include path list. The needed directory would be the one referred to by <foo>, though.
On top of that, -I- is deprecated since at least GCC 4.1, so *PLEASE* add an option to remove it - I additionally noticed that "." is always added as an include directory as well - how about a text box in the Advanced compiler options "Others" page which holds the "default include directives"?