Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Specify base directory for "Add Include"
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MikeTomato
Junior Member

21 Posts

Posted - Oct 26 2016 :  11:38:58 AM  Show Profile  Reply with Quote
I use the "Add Include" command a lot. Unfortunately more often than not I get a very short include path regardless of the "Add Include Style". At our company all our source code is in different directories under one base directoy called "Source". The directory structure would look like this

Source/Project1
Source/Project2
Source/MoreProjects
Source/MoreProjects/Project3

In each of our projects the "Source" directory is specified as an additional include directory. Every include path has to start below the source directory, like this

#include <Project1/Header1.h>
#include <Project2/Header2.h>
#include <MoreProjects/Project3/Header3.h>

It would be really helpfull if I could specify the "Source" directory as a base directory in Visual Assist, too.

Kind regards

Michael

Edited by - MikeTomato on Oct 26 2016 11:39:52 AM

accord
Whole Tomato Software

United Kingdom
3137 Posts

Posted - Oct 26 2016 :  11:49:19 AM  Show Profile  Reply with Quote
Have you tried this option?
https://docs.wholetomato.com/default.asp?W336

It is not exactly what you are asking for but it seems to be closer to that.
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Oct 27 2016 :  03:30:06 AM  Show Profile  Reply with Quote
Yes, I tried the registry setting, too. Sometimes I just get the header file and sometimes I get a medium long include path, but never a long include path. Here is an example

Source/Project1/SubDirectory/Example1.cpp
Source/Project2/Example2.h

Example2.h contains declaration of class A. If I use class A in Example1.cpp and use "add include" I get
#include <Example2.h>
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Oct 27 2016 :  04:19:48 AM  Show Profile  Reply with Quote
Here is another customer who has the same feature request

http://forums.wholetomato.com/forum/topic.asp?TOPIC_ID=12695
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3137 Posts

Posted - Oct 27 2016 :  11:54:06 AM  Show Profile  Reply with Quote
Yes, you're right, it is case=33851. I have added a comment to show your interest about this feature.
Go to Top of Page

sean
Whole Tomato Software

USA
2574 Posts

Posted - Sep 24 2018 :  2:30:31 PM  Show Profile  Reply with Quote
case=33851 is implemented in build 2291 -- see Add Include path on the Code Generation page of the VA Options dlg.
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Sep 25 2018 :  04:52:33 AM  Show Profile  Reply with Quote
Hi Sean,

I installed the latest build. Which of the three options "Use shortest possible path", "Prefer path without ..\", "Prefer path relative to project" should I use. It seems none of them are working for me. I set "HKCU \ Software \ Whole Tomato \ Visual Assist X \ <IDE spec> \ AddIncludePreferShortestRelativePath = 0", too.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15715 Posts

Posted - Sep 25 2018 :  10:02:01 AM  Show Profile  Reply with Quote
Using VS2017 and VA 2291 I have create a new, default C++ console project, and set up the following test files:

C:\src\add_include_console\add_include_console.SLN
C:\src\add_include_console\add_include_console\add_include_console.VCXPROJ

C:\src\add_include_console\add_include_console\Project1\SubDirectory\Example.cpp

C:\src\add_include_console\add_include_console\Project1\Header1.h
C:\src\add_include_console\add_include_console\Project2\Example2.h
C:\src\add_include_console\add_include_console\Project2\Header2.h
C:\src\add_include_console\add_include_console\MoreProjects\Project3\Header3.h

taken from your examples above. All of these code files have been added to the project. Since I have used the directory with the .VCXPROJ file as my base, this is already a known directory to use for reference for include paths.

I have a test class in each of the header files, and I make instances of each class in the "example.cpp" file. With the VA settings:

VA Options->Code Generation->Add Include style = <>
VA Options->Code Generation->Add Include path = Prefer path relative to project

Add Include for each of these test classes gives me:

#include <Project2/Example2.h>
#include <../Header1.h>
#include <Project2/Header2.h>
#include <MoreProjects/Project3/Header3.h>

which seems to be the result you are looking for.

I can send you the test solution if you want to look at it directly? This is a little complex to explain here, but I think I have set up a reasonable test for your situation, and what I am getting seems correct.

The registry key setting AddIncludePreferShortestRelativePath is not having any effect on my results.

zen is the art of being at one with the two'ness
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Sep 25 2018 :  10:12:20 AM  Show Profile  Reply with Quote
In my solution each of the projects (Project1, Project2, Project3) has its own vcxproj-file.
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Sep 25 2018 :  10:15:37 AM  Show Profile  Reply with Quote
In your example I would have expected #include <Project/Header1.h> instead of #include <../Header1.h>, regardless of the fact that Example.cpp is in the same "Project" Project1.
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Sep 25 2018 :  10:19:27 AM  Show Profile  Reply with Quote
The easiest solution for me would be an Option "Specify root directoy" on the Code Generation page of the VA Options dlg. There I could specify the root directoy for includes as i.e. C:\src\add_include_console\add_include_console
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15715 Posts

Posted - Sep 25 2018 :  11:14:15 AM  Show Profile  Reply with Quote
The problem with a setting like this is that it is solution specific. If you only ever have one solution then this is OK, but it's not really a general solution.

I am going to set up another test solution, with multiple project files. The closer I get to what you are doing, the clearer the bug report will be.

zen is the art of being at one with the two'ness
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Sep 25 2018 :  12:03:55 PM  Show Profile  Reply with Quote
"If you only ever have one solution then this is OK, but it's not really a general solution." You're right, I do have only one solution file. I had not considered, that that is not the average case.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15715 Posts

Posted - Sep 26 2018 :  1:38:34 PM  Show Profile  Reply with Quote
I think a reasonable general solution would be a setting that generated a #include path that never starts with ..
This might not always work, but in your situation it should always be possible to do this, since your include directories are setup to allow this. The down side is that it isn't guaranteed to always start at "Source", since sometimes there will be a shorter path that still complies with this rule. Would this be close enough to work well here?

zen is the art of being at one with the two'ness
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Sep 27 2018 :  04:44:00 AM  Show Profile  Reply with Quote
I'm sorry but I do not understand this rule. With what would ".." be replaced?

I would like to give you some more facts about my problem

1) "Add include" always works, if the header is in a different Project. That would be "#include <Project2/Header2.h>" in your example.
2) As soon as I want to add a include of the same project I get a short include path. Like "#include <Header1.h>" in your example.

Thank you very much for your efforts.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15715 Posts

Posted - Sep 27 2018 :  11:33:20 AM  Show Profile  Reply with Quote
Since you want all #include statements to start with the same base directory, do you have any other Additional Include Directories set in your projects that point to inside your solution directory tree?

If VA looks at all of your Include Directories, and only one of these is a valid root directory, then we could have a rule that says in this case always use this as a root directory. This would require having to set this directory, which does not work as soon as you change solutions.

I am looking for some general solution that will tell VA what you want to achieve here.

zen is the art of being at one with the two'ness
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Sep 28 2018 :  04:34:53 AM  Show Profile  Reply with Quote
These are our companywide Additional Include Directories

$(IsdRootFolder)Source\incc\ // Some very old includes. Doesn't matter
$(IsdRootFolder)Source\Projekte\ // THE root directory
$(IsdRootFolder)externalSDKs\boost\include\ // Boost
$(IsdRootFolder)externalSDKs\cppunit\include\ // CppUnit

with IsdRootFolder == D:\usr3\hicad
All include statetements are relative to the root directory.



Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15715 Posts

Posted - Sep 28 2018 :  07:15:41 AM  Show Profile  Reply with Quote
So this would actually work, at least for files inside your solution, under the root directory.

If the same rule was applied to all header files, would this cause any problems? If you have one rule for all include files then this looks like a well defined rule. But if you have different rules for different classes of include file then we are back to having a mess.

zen is the art of being at one with the two'ness
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Sep 28 2018 :  09:17:23 AM  Show Profile  Reply with Quote
We have one rule to rule them all.
Even headers in non-root-directories are included realtive to the root-directory. A header header1.h in incc would be included as #include <../incc/header1.h>. The same applies to externalSDKs.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15715 Posts

Posted - Sep 29 2018 :  07:10:36 AM  Show Profile  Reply with Quote
So even Boost header files are included relative to the root directory?

If it isn't a silly question, why add the other include directories then? If these are present, then code that breaks this rule will still work and compile. But by removing these additional directories you force everyone to stick to this rule. And as a side effect, VA should tend to stick more closely to the rule as well.

With all 4 directories listed, I don't see any sensible rule we can give VA that will scale well and work more generally for other solutions.

zen is the art of being at one with the two'ness
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3137 Posts

Posted - Sep 29 2018 :  10:44:06 PM  Show Profile  Reply with Quote
In order for the "Prefer path relative to project" option to add the directory relative to the project, you need
1. to add the directory to "Additional Include Directories" of the project
2. use Add Include to add a header that is not a library include, and that it is from the same project as the active file
3. if the active file is added to multiple projects, make sure those projects are in the same directory AND both of them are added to Additional Includes as per #1

If the above criteria is not met, Add Include will fall back to the default option.

Does this make sense?

I'll look into feline's test solution, why does it include this result:

#include <../Header1.h>

Edited by - accord on Sep 29 2018 10:49:49 PM
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Oct 04 2018 :  03:42:04 AM  Show Profile  Reply with Quote
@feline: You're right and it's not a silly question. $(IsdRootFolder)Source\Projekte\ would be sufficient. "But by removing these additional directories you force everyone to stick to this rule." There are "hot" discussions about this issue in our company. I could enforce this rule in the projects I'm working on.
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Oct 04 2018 :  03:52:58 AM  Show Profile  Reply with Quote
@accord:
1. That would be my root directory. Done
2. Usually the includes are no library includes. Done
Why must the header be in the same directoy as the active file?
3. Usually each file is in only one project. Done
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15715 Posts

Posted - Oct 06 2018 :  09:51:16 AM  Show Profile  Reply with Quote
Is there a fairly simple rule that we could apply that would have the desired result on Add Include in your situation? If there was only one additional include directory to check then it would be fairly simple and well defined to put in a feature request for this.

The problem with adding a specific setting is that this is a very specific setting for a very specific situation. Plus, if you ever check out into a different root directory, even just changing the base drive letter, the setting may stop working for you as well.

zen is the art of being at one with the two'ness
Go to Top of Page

MikeTomato
Junior Member

21 Posts

Posted - Oct 08 2018 :  09:37:36 AM  Show Profile  Reply with Quote
How about: Add include relative to first additional include directory of current project.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15715 Posts

Posted - Oct 08 2018 :  10:45:59 AM  Show Profile  Reply with Quote
I have put in a feature request for this to see what our developers make of it. But since this is such a specific and particular rule, I am not sure how quickly we will look at this.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2018 Whole Tomato Software, Inc Go To Top Of Page
Snitz Forums 2000