Bug 273837 - custom include paths have lower search priority than system includes
Summary: custom include paths have lower search priority than system includes
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: 4.2.1
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-22 07:47 UTC by julee
Modified: 2014-08-05 09:52 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description julee 2011-05-22 07:47:50 UTC
Version:           4.2.1 (using KDE 4.6.3) 
OS:                Linux

In c/c++ project, #include "filename.h" means search filename.h in project firstly.If the file cannot be found,then search in system directory.
Howerver,when kdevelop parsing this comment,it search in system directory firstly.
If there is a header file in system directory which it's  name is same as cureent project's header file,this   incorrect parsing priority will cause an  parsing error.

Reproducible: Always
Comment 1 Milian Wolff 2011-05-27 18:20:26 UTC
cannot reproduce, it works as you suggest for me.

please attach a simple project that exhibits this behavior (i.e. two files where one is called like a common system header).
Comment 2 julee 2011-05-29 09:09:09 UTC
(In reply to comment #1)
> cannot reproduce, it works as you suggest for me.
> 
> please attach a simple project that exhibits this behavior (i.e. two files
> where one is called like a common system header).

Sorry,seems that there is no bug in search-priority for parsing header files as you say.
However, there is some trouble in searching header files with imported makefile project.That is,in some makefile project,header files was in several sub-directory of the project,but it's source file include those header files with statement 
' include "filename" ' ,no pathname of sub-directory.And in makefile,the project use flags like "-I sub-directory' to help compiler locate those header files,and those sub-directory has a higher priority than system header directory.
Unfortunately,kdevelop cannot settle with those -I flags from imported Makefile project. So,users should add those sub-directory to the file .kdev_include_paths to help kdevelop to search those header files.But those directory in  .kdev_include_paths has a lower search-priority than system header files directory.

For example:
Makefile Project Test:

in sub-directory Test/os_include:

//stdio.h
inline void func() {}

In directory Test:

Makefile:
INCLUDEPATH:=-I os_include/
test:test.cpp
	g++ $(INCLUDEPATH) -o test test.cpp


//test.cpp
#include "stdio.h"  //defined by user. Not like  pathname/headerfile,but is legal.Complier use -I flags to find  stdio.h in project.

int main()
{
  func();
}

Use make ,the proeject can compile successfully.
Import this project to kdevelop,I have to add the full path name of os_include to   the file .kdev_include_paths to make kdevelop parse header files in this directory,because kdevelop cannot settle with -I flags to find extra include-directory.
But,kdevelop with search system include-directory firstly such as /usr/include,then directory in .kdev_include_paths.
This cause , in this project ,#include "stdio.h" ,stdio was parsed to /usr/include/stdio.h
Comment 3 Milian Wolff 2011-05-30 15:41:10 UTC
no time to confirm it now but I'll trust you with that.
Comment 4 Kevin Funk 2014-04-06 01:33:37 UTC
Is this still valid?
Comment 5 Sergey Kalinichev 2014-08-05 09:52:24 UTC
This is fixed in custom-definesandincludes plugin.