Author Topic: Add #include in C++ does not work with directory tree?  (Read 2450 times)

fritzeflink

  • Community Member
  • Posts: 55
  • Hero Points: 2
Add #include in C++ does not work with directory tree?
« on: May 04, 2019, 07:46:09 AM »
I just decided to organize my C++ project into subdirectories since I had a several hundred files all in one directory. Now, when I use Add #include on an unknown symbol I get an error message that the relative path can not be resolved. When I hover over the symbol it shows all info, so it clearly knows in which file it is. This is true with or without qualifying namespace prefixes. The VisualStudio project file has all the paths to the new subdirectories set under "additional include directories" so all it needs to do is add a plain #include "xx.h" without relative path.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Add #include in C++ does not work with directory tree?
« Reply #1 on: May 04, 2019, 09:29:37 AM »
What do you mean by "Add #include on an unknown symbol"?

In project properties, Directories tab, "Includes", try adding all the paths to the extra folders.

Dennis

  • Senior Community Member
  • Posts: 3961
  • Hero Points: 517
Re: Add #include in C++ does not work with directory tree?
« Reply #2 on: May 06, 2019, 07:40:48 PM »
Finding a relative #include path is currently a limitation in the implementation of "Add #include", which is a fairly new feature.  I will add a feature request to look at improving it in the next release.

@Graeme:  This feature can by found by right-clicking on a symbol in the editor and selecting "Imports > Add #include for XXX" or "Import > Go to #include for XXX".  For C++, I generally prefer to use "Go to #include, because that way if it adds a #include statement, I can see if it landed where I want it, because C++ #includes can be a bit persnickity unless code is really well formed, which is, unfortunately, one of the rarest things on this planet.
« Last Edit: May 06, 2019, 08:14:00 PM by Dennis »

Dennis

  • Senior Community Member
  • Posts: 3961
  • Hero Points: 517
Re: Add #include in C++ does not work with directory tree?
« Reply #3 on: May 06, 2019, 08:04:24 PM »
Actually, this feature does work correctly when the #include paths are found and understood by SlickEdit.  Without seeing your Visual Studio project, I have no idea why SlickEdit is not picking up the paths as you would expect.

You can debug this command by running "codehelp_trace_add_import" from the SlickEdit command line.  A slew of debug information will be dumped out to the SlickEdit debug output window.

fritzeflink

  • Community Member
  • Posts: 55
  • Hero Points: 2
Re: Add #include in C++ does not work with directory tree?
« Reply #4 on: May 17, 2019, 08:37:35 AM »
Ok, I didn't know I had to add the search paths in the Project Properties tab as well. I added them in the Visual Studio project and I assumed Slieckedit would get the search path's from there. So I have to add the same directories to the Slickedit project and it works, it now adds the correct relative paths to the include statement.

Thanks for the answer.