Clion code inspection not working

Clion static code analysis is highlight a lot of errors about missing definition and files, but its already included in the project.

Simple example is the std::unique_ptr. Code inspection highlights that there is no unique_ptr in std, but when I control click on unique_ptr it takes me to the header file in std lib.

Same with a lot of other line, its says the definition of the function is not found, but when I control click it takes me to the correct definition.

I've included these files correctly in the CMakeLists.txt file. Is control+click using a different method to find the definition?

0
10 comments
Avatar
Permanently deleted user

In my past experience, if the definition and the library can be found but says it can't be found upon use, then it is a header issue.

0

Hello!

What CLion version and what toolchain do you use? On what OS? Is the CMake project loaded successfully? Do Tools | CMake | Reset Cache and Reload Project and File | Invalidate Caches / Restart ... help? Is the issue reproducible with a default "C++ Executable" project created in CLion?

2
Avatar
Permanently deleted user

Clion version 2018.3 and I'm using built in Cmake on Ubuntu 16.04. Tried Resetting Cache and Restating, doesn't help. 

Also want to add, I'm using CMakeList.txt only for adding files for indexing for CLion. To actually build the project we are using internal tool that's based on CMake.

 

 

0

Do you have any errors in the CMake tool window (View | Tool Windows | CMake)? 

Do you observe the issue in source or header files? How do you add files in the CMakeLists.txt? Do you add all files? 

Please provide a screenshot of File | Settings | Build, Execution, Deployment | Toolchains.

0
Avatar
Permanently deleted user

> Do you observe the issue in source or header files? How do you add files in the CMakeLists.txt? Do you add all files? 

I think the issue is related to this. In my code when including the header files I need to add relative path from the current file location, then it works. 

If my CMakeList.txt file has say include_dir(include_path)

Code: 

#include <header.h> // Doesn't work

#include <../include_path/header.h> works.

Not sure if its because my Cmake files in more than 3K lines. 

 

> Do you have any errors in the CMake tool window (View | Tool Windows | CMake)? 

It says "failed to reload", but I checked the logs in cmake-build-debug folder and I don't see any errors there. I think its because Clion is timing out before CMake rebuilding completes.  

 

> Please provide a screenshot of File | Settings | Build, Execution, Deployment | Toolchains.

Everything is default here - Bundled CMake version 3.13.2, C++ compiler -> /usr/bin/c++.

 

0

>It says "failed to reload"

CLion uses a concept of a project and relies on CMake as a build system for it. All the includes paths, variables and more is taken from CMake files and are used by CLion to understand your project better and to resolve your code correctly. So a CMake project should be successfully loaded so that CLion could provide code insight features.

 

0
Avatar
Permanently deleted user

But it does not say why it failed. How do I find the reason it failed ? I checked all the log files in cmake-build-debug folder and I don't see any errors there.

Also when I run the command that Clion uses for cmake manually from terminal I don't see any errors there either.

0

What do you see in the CMake tool window after Tools | CMake | Reset Cache and Reload Project?

0
Avatar
Permanently deleted user

/snap/clion/58/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" <Project Root>
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: <Project Root>


[Failed to reload]


It doesn't say why it failed to reload through. Which log file should I check ?

0

You can check whether CMakeOutput.log and CMakeError.log exist in the cmake-build-debug/release folder. Also you can check whether there are any issues in the idea.log file (Help | Show Log in ...).

0

Please sign in to leave a comment.