简体   繁体   中英

CLion cannot detect classes from sources, and does not have intellisense / code completion

I'm using CLion so I can (hopefully) have the ability to:

  • Have code completion for a file type that is registered as a c++ file (In my case the file type is called .hps)
  • Make full use of the error hightailing features and all of the intellisense on my .hps files
  • Be able to use classes from other hps files, located in different folders in my project.

The general c++ style coloring is working, however, CLion won't notify me about syntax errors inside hps files:

CLion不会通知我有关hps文件中的语法错误的信息

  • CLion won't find the source files I include, and therefore won't detect any classes that are declared inside other hps files and their methods (all of the folders that include that hps files are located inside a folder named "script"

Implementation of what I'm trying to include:

我要包含的内容的实现

And as you can see, it does not detect it:

如您所见,它无法检测到它

Now, this is the setup of my project:

  1. My project is located and opened at folder that has a folder inside it called "script" in which all of the .hps files I include are there.
  2. I've set a CMakeLists.txt file that runs on MinGW environment. This is the full content of that file:

    这是该文件的全部内容

  3. There is a file, in my PARENT folder, called hps_api.hps, that consists classes declarations as well. Note that CLion won't detect it as well. Did I do something wrong? The only thing I pretty much did was to add include directories to the cmake file, but I guess it's not enough?

In another program called CodeLite for example, it's possible to just add to a list a path to search files to include, and then CodeLite parses those files and I can go to declarations of classes without any problems. Surely it's possible with CLion as well, right?

Syntax Errors

Is it possible that you have Power Save Mode activated from the File menu? If it is activated, some code-parsing features may be disabled.

File Type .hps

I am guessing you already have the file type .hps registered as a C/C++ file in Settings -> Editor -> File Types . If not, you should register it!

CMakeLists

You might need to configure some more properties like the project name and a target to associate the project with the files you are using.

cmake_minimum_required(VERSION 3.12)
project(YourProjectName VERSION 0.1.0)

include_directories(script/agents)
include_directories(script/areas)
include_directories(script/base)

add_executable(YourProjectName main.cpp header1.hpp source1.cpp path/to/header2.hpp path/to/source2.cpp)

If you are not building an executable, but a library, you might need to use add_library instead. For the syntax you can check the documentation .

I hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM