Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with .ccls file config: Header file correctly parsed but "file not found" error appears. #97

Open
grivasgervilla opened this issue Jul 31, 2020 · 0 comments

Comments

@grivasgervilla
Copy link

grivasgervilla commented Jul 31, 2020

Hi everyone,
I have recently configured my Doom Emacs to use ccls as my C++ server for LSP. The completion seems to work perfectly. However, in every single cpp file where I make an #include of some of my own hpp files, I got the error "file not found", and I do not know how to setup my .ccls file in my project root, so these files are found.

System Specs

  • SO: Arch Linux 5.7.10-arch1-1
  • clangd: 10.0.1
  • ccls: ccls 0.20190823.6-2
  • Emacs: GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20) of 2020-05-19
    • Doom Emacs: Doom Emacs 2.0.9
    • lsp-mode: Release 7.0
    • emacs-ccls: 0.1

Project Structure

.
├── .ccls
├── .dir-locals.el
├── .gitignore
├── include
│   ├── constants.hpp
│   ├── Context.hpp
│   ├── Graph.hpp
│   ├── Lattice.hpp
│   └── utilities.hpp
├── Makefile
├── README.md
└── src
    ├── Context.cpp
    ├── experimentation.cpp
    ├── Graph.cpp
    ├── Lattice.cpp
    ├── main.cpp
    ├── parallelism.cpp
    └── utilities.cpp

Files

I think that the following files of my project would be enough to reproduce my error. I pick the include/Context.hpp and src/Context.cpp files because the cpp file only include this hpp file from my project:

/**
* @file constants.hpp
* @author griger
*/

#ifndef __CONSTANTS__
#define __CONSTANTS__

const int TMAX = 10000;

#endif
/**
 * @file Context.hpp
 * @author griger
 * */

#include <bitset>
#include <iostream>
#include <vector>
#include <map>

#include "constants.hpp"

using namespace std;

#ifndef __CONTEXT__
#define __CONTEXT__

class Context {
        private:
                size_t nObj, nProp;
                map<int, bitset<TMAX>> Intents;
                vector<vector<bool>> table;

        public:
                Context();
               
                Context(vector<vector<bool>> data);
               
                size_t getNObjects() const {return nObj;}

                size_t getNProperties() const {return nProp;}
                
               
                bitset<TMAX>& operator[](int objID) {return Intents[objID];}
                const bitset<TMAX>& operator[](int objID) const {return Intents.at(objID);}
};

ostream& operator<<(ostream& os, Context& c);

#endif
/**
 * @file Context.cpp
 * @author griger
 * */
#include <math.h>

#include "Context.hpp"

Context::Context(){
    nObj = nProp = 0;
}

Context::Context(vector<vector<bool>> data){
    table = data;
    nObj = data.size();
    nProp = data.at(0).size();

    int objID = 0;
    for (const auto& row : data){
        Intents[objID] = bitset<TMAX>();
        int propID = 0;

        for (bool col : row){
            if (col)
                Intents[objID].set(propID);
            
            propID++;
        }

        objID++;
    }       
 }

ostream& operator<<(ostream& os, Context& c){
    for (size_t objID = 0; objID < c.getNObjects(); objID++)
        cout << "Objeto " << objID << " Propiedades: " << c[objID] << endl;

    return os;    
}

.ccls

I have also tried -std=c++17 flag, but the same error occurs.

clang
%cpp %hpp -std=c++2a
%cpp %hpp -Iinclude
-Iinclude

Error

prueba

As you can see a "File not found" error appears. However, there is no error about Context not being defined or something like that. In fact, the autocompletion for the Context instances methods works fine.

I have read in some similar issues for this repo or the ccls repo, that flycheck may have something to do with this problem. But I have tried to disable flycheck, but then other proper errors are not being highlighted...

Many thanks for your time 😄.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant