Replies: 1 comment
-
I saw similar problem to you. You do need to build the project at least once to get the information. Before I do the build (which creates the You can turn on All that said...
Although I shouldn't have to do it, if I run rebuild index I get the expected results. I don't know what else is going on for you. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,


I am using eclipse-cpp to create a CMake project.
Steps: First, I went to File->New->"C/C++ Project".
This brings up a modal pop-up titled "New C/C++ Project". From this I chose the Template "CMake Project" (not "Empty or Existing CMake Project".)
I named the project "hello_world", and clicked finish.
Eclipse/CMake didn't give a choice of whether to chose to make it a .c or .cpp file, it just went with .cpp.
Opening even this simple hello_world.cpp in the editor displays several 'false' errors on unrecognized symbols and includes.
Of course the project will build successfully and it can be run/debugged successfully.
Similarly, if I replace this with a hello_world.c, it too compiles and runs but the editor view is again full of claimed errors
Attempts to do Index-> 'Rebuild' or 'Freshen All Files', do not fix this.


One can of course 'Search for Unresolved Includes'. But what to do with that information? Unlike other project types there is nothing in Project Properties that would offer a way to add Paths or Symbols, to let CDT know where to look for this info. This is what one sees instead.
Contrast that with the Project Properties options available to the same hello world experiment created instead via File->New->"C/C++ Project" and then Template choice "C Managed Build".
I dimly understand that in this CMake use case the CDT indexer doesn't have the information it needs to generate a worthwhile index. But how do I get CMake, (or myself--happy to edit dotfiles or whatever within reason) to supply this information?
Should I not even be attempting to make a project this way?
Ought I instead be creating a managed build type project and then layering CMake on top of it?
I have seen similar queries sprinkled through the eclipse forum and stackoverflow dating back to when Eclipse didn't yet have built-in CMake support. Some of these talk about various things one might add to the CMakeLists.txt file to use or not use a 'response file' or have CMake emit a compile_commands.json that CDT could use as for indexing. However, none seemed to work for all queriers.
In short, how do I help CMake help CDT build its index? Is there some doc somewhere that I may have missed?
Beta Was this translation helpful? Give feedback.
All reactions