2

I am about to configure KDevelop (5.2.1) for a C++ project using CMake on Archlinux. Building my project in KDevelop as well as from the command line works but I hit several parser problems for code completion:

  1. In the beginning my includes of C++ standard library headers like

    #include <cstdlib>
    

    where not associated to the headers found at the default system include directories. I need to add those directories in Project->Open Configuration->Language Support->Includes/Imports:

    /usr/include/
    /usr/include/c++/7.2.1/
    

    For C headers it looks fairly simple. In case of C++ this seems nasty as it looks like it could change from time to time.

    Is there a more reliable and project independent way to perform this configuration?

  2. The parser misses some declarations in local header files dependent of the list of configured include directories. For example the QuadMatrix class is declared in include/quadmatrix.h. In the code

    #include <cstdlib>
    
    #include "quadmatrix.h"
    
    
    QuadMatrix::QuadMatrix(int dimSize)
        : dimSize(dimSize)
    {
        data = (int*) std::malloc(sizeof(int) * 2 * dimSize);
    }
    

    QuadMatrix is an "undeclared identifier" for the parser when I configure the system include directories as in 1 . If I reset this configuration cstdlib and std::malloc are unknown but QuadMatrix is finally declared.

    I also tried to add the project include directory to the configuration but it did not change anything and it was not neccessary in the first place.

    Interestingly the editor advises me to add #include <quadmatrix.h> in both cases but this can't fix the problem either.

Edit: I found out that using GCC instead of Clang under Project->Open Configuration->Language Support->C/C++ Parser (right bottom corner) solves my problem and makes any of my include directory configuration unneccessary. So I guess KDevelop uses the clang parser (5.0) in a wrong way.

0 Answers0