I have spent a lot of time playing with the Kdevelop configuration for the C++ parser. However I cannot get the clang parser to work with STL header (for example). I am not using c++11 but even with the default settings of std=c++11, the STL headers are not fully recognized. If I explicitly include a path to find /usr/include/c++/6.2.1 then the STL headers are found, but typedefs are not recognized. Simple example. #include <string> using namespace std; string myString; This is what the parser will show for string. typedef int string Container: std Kind: Typedef Decl.: stringfwd.h :74 Show uses It does not seem to find the real typedef which should be: typedef basic_string<char> string; My guess is that the clang parser is not going deep enough to resolve these types. It appears it gives up and the uses the default type of int for anything it doesn't know. What are the correct settings to get the clang parser to work? I have spent hours on trying to find a solution to no avail.
The settings I am referring to are under project->Open Configuration...->Language Support Maybe this is an issue with c++11 v.s. older ABI When I pulled up a project that had c++11 for the language version then I do see std::string interpreted correctly: typedef basic_string< char, std< char >, std< char > > string Container: __cxx11 Kind: Typedef Decl.: stringfwd.h :74 Show uses If I try to use 03 it reverts to this: typedef int string Container: __cxx11 Kind: Typedef Decl.: stringfwd.h :74 Show uses If I include the define for _GLIBCXX_USE_CXX11_ABI 0 then back to this: (Using 03 or 11, doesn't matter). typedef int string Container: std Kind: Typedef Decl.: stringfwd.h :74 Show uses
Further strangeness: I have found while initially reparsing my project with the only change in project->Open Configuration...->Language Support _GLIBCXX_USE_CXX11_ABI 0 std::string Show correctly typedef basic_string< char, std< char >, std< char > > string Container: std Kind: Typedef Decl.: stringfwd.h :74 Show uses But somewhere during the reparsing back to this: typedef int string Container: std Kind: Typedef Decl.: stringfwd.h :74 Show uses
Looks like this has boiled down to the lack of pkg-config support. I am using glib and in my Makefile I use `pkg-config glib-2.0 --cflags` As you may know, this will provide the paths: -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include It appears that the clang parser will not be able to parse if these paths are not present and hence the strange behavior with the STL includes. Is there a way to add the pkg-config support into the parser?
The whole problem was relying on the Makefile to supply the include paths. Apparently KDevelop does not parse pkg-config entires in the Makefile. I added the needed include files paths in Kdevelop and resolved the problem.
I must say that with my issues resolved, the Background parser is working very well. I am very impressed with Kdevelop 5.x.x.
Thanks, glad you figured out how to solve the problems!
I would like to add a comment that may help others stumbling across this issue. If there are any RED issues reported in Problems for include files, the parser will not work. You must resolve these problems in order for the parser to work again.