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

fritzeflink

  • Community Member
  • Posts: 32
  • Hero Points: 1
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: 2366
  • Hero Points: 313
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

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2821
  • Hero Points: 426
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

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2821
  • Hero Points: 426
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: 32
  • Hero Points: 1
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.