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
 Technical Support
 1544: resolving operator[]
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jan 25 2007 :  5:50:26 PM  Show Profile  Reply with Quote

template <class T> class tArray {
public:
	T* vector;
	T& operator[](int index) const
	{
		return vector[index];
	}
};

template <class T> class tRef {
public:
	T* Ptr;
	T* operator->() const
	{
		return Ptr;
	}
};

template <class T> class tRefArray
{
public:
	tArray <tRef<T>*> Array;

	tRef<T>& operator[](int index)
	{
		return *Array[index];
	}
};



class cTest1 {
public:
	int Apple;
	int Banana;
};

class cTest2 {
	tRefArray <cTest1> K;
	void Func(void)
	{
		K[0]->Ptr;
	}
};


In this code, if I type K[0]-> into Func() i get completion listbox with these items:

operator ->
Ptr

...which is wrong. VAX should display

Apple
Banana

Certainly when I try to complile the code I have inserted, I get the

error C2039: 'Ptr' : is not a member of 'cTest1'

compiler error message.

(I can reproduce it in a new win32 project. I have inserted the code into the cpp file)

khb
Tomato Guru

Germany
337 Posts

Posted - Jan 26 2007 :  02:25:12 AM  Show Profile  Reply with Quote
I had a very similar problem yesterday. There, VAX also showed wrong entries in the suggestion list when accessing items of an array. I cut it down to this (I hope it wasn't too much cutting):
#include <vector>
using namespace std;

struct myStruct
{
    int i;
    double d;
};

class myClass
{
    myClass();
    vector<myStruct> m_myVector;
};

myClass::myClass()
{
    m_myVector[0].|
}
In this example I expect to get i and d as suggestion, but nothing is suggested when pressing Ctrl+Space.

Regards,
Marcus.
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jan 26 2007 :  06:15:41 AM  Show Profile  Reply with Quote
When I turning off "Guess contents if unknown" I also get nothing. When this option is checked, I get the wrong suggestion list. It is pretty logical. VAX used the alternative method to populate the list. (But this is not reproducable, because sometimes VAX also pupolate the list when this option is turned off)

Feline: "Get content from default intellisense" also did't worked for me.

VAX 1544, WinXP SP2, VS2005 SP1
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Jan 26 2007 :  12:39:03 PM  Show Profile  Reply with Quote
khb do you see the problem with this very cut down test? Once VA has parsed the code (I am doing a copy / paste) I am getting just two items in a completion listbox.

accord have you placed this code into a cpp or .h file? using VS2005 SP1 and VA 1544 I have tried this on two different machines, and I am seeing the same effect on both. With

VA Options -> Text Editor -> listboxes -> Get content from default Intellisense

turned off I see:



and with it turned on I see:



I just did a copy / paste of the entire code block, so there should not be any differences to explain this.

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

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Jan 26 2007 :  1:16:22 PM  Show Profile  Reply with Quote
I have put in a bug report for getting the wrong suggestions from VA

case=4733

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

khb
Tomato Guru

Germany
337 Posts

Posted - Jan 29 2007 :  02:07:30 AM  Show Profile  Reply with Quote
I just retried it: I get no suggestion for the cut down test. I forgot to mention that I use VC6 with build 1544. And I have "Get content from default Intellisense" enabled.

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Jan 29 2007 :  09:27:05 AM  Show Profile  Reply with Quote
kbh what happens if you turn off "Get content from default Intellisense"? I have just tried the simple example you posted at "Jan 26 2007 : 02:25:12 AM" using VC6 and VA 1544 and I am getting a completion listbox when I type the dot.

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

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jan 29 2007 :  1:51:34 PM  Show Profile  Reply with Quote
>accord have you placed this code into a cpp or .h file?
into the cpp file.

After a lot of fiddling, I have successfully got the desired listbox from Intellisense. It was required to proceed 3 steps:

1. I have deleted the .ncb file that forced intellisense to reparse my solution. This helped in the test project, but failed in real environment. I had to make 2 more modifications to get intellisense to work in a real environment.

2. I have merged my 3 template class into 1 file.

3. I changed my "include files" path under VC++ directories to absolute one including the drive letter. Before this, I used include pathnames begining with "\\". Interestingly the compiler accepted it, but intellisense not.

(Certainly I have deleted the .ncb file before each try.)

But Find References, Rename and other VAX functions still not working in this case, so case 4733 should be fixed.

Thanks for your help Feline Your response motivated me to figure out how can I get intellisense to work
Go to Top of Page

khb
Tomato Guru

Germany
337 Posts

Posted - Jan 30 2007 :  02:08:40 AM  Show Profile  Reply with Quote
Switching "Get content from default Intellisense" on/off doesn't make any difference. I still get no suggestion for the example.

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Jan 30 2007 :  4:07:18 PM  Show Profile  Reply with Quote
khb using VC6 and VA 1544 I have just created a new console application. When asked I selected "simple application" rather than "empty project".

I then pasted the same code into the cpp file, above the main function.

with Get content from default Intellisense turned Off I get a completion listbox immediately when I type the dot.
with it turned On I have to press CTRL-SPACE, and then I get the completion listbox.

If you email me via the forum I can reply with a zip of this test project attached, if this might help. This is "just working" for me, and so far I cannot see any reason why it should not work for you.

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

khb
Tomato Guru

Germany
337 Posts

Posted - Jan 31 2007 :  02:29:31 AM  Show Profile  Reply with Quote
I just tried a new "simple" console application as well as a new MFC application. In both cases I get exactly the behavior you describe. However, in my "real" (MFC) application I tried to put that code in different files and I get no suggestions at all. Anyway, a more severe problem is that for the arrays (vectors) I use there, I get a suggestion list, but with wrong entries.
Either I get members of the vector class or of a completely different struct that is defined within the project. I noticed this problem first with 1544, but I'm not sure if it's, e.g., already in 1543, too, but it worked before with 15xx builds for sure.

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Jan 31 2007 :  12:18:48 PM  Show Profile  Reply with Quote
I agree, a fairly serious problem. Are you simply creating these variables like this:

std::vector<CFoo> m_bar;

or are you doing something more subtle?

When you place the caret inside the variable name what does VA show in the wizard bar?

Since this works correctly in the test project, but not in the main project can you try closing the IDE and deleting your NCB file? This is a long shot, but it might help. Certainly this is a project specific file.

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

khb
Tomato Guru

Germany
337 Posts

Posted - Feb 01 2007 :  09:48:47 AM  Show Profile  Reply with Quote
I have a simple struct, lets call it X. Then I have a class A where I have a member std::vector<X> m_vec. Then, in the code I have lines like if(m_vec[i].abc != NULL). The tooltip on this line shows std::vector<X> A::m_vec. This looks alright to me, but when I type Ctrl+Space after m_vec[i]. to get a list of the variables contained in X, then I just get all members of the vector class itself (beginning with _Charalloc).

Then I removed the .ncb file of the corresponding project and opened the IDE again. Now I got suggestions like _Mask, _Ptr, etc. when typing Ctrl+Space after m_vec[i]. and I have no idea where they come from.

Then something strange happened. I had to walk of and came back three hours later. I again tried the Ctrl+Space thing and now I got suggestions of another struct that is defined in the project. I then again removed the .ncb file and ended up with the suggestions _Mask, _Ptr, etc. again.

*giga confusion*

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 01 2007 :  12:31:05 PM  Show Profile  Reply with Quote
Do any vector's in your code give sensible suggestions when doing this?

I think this may be

case=961

however I was never able to reliably reproduce this problem on demand. Can you produce one of these listboxes and check the content of the list. Are the components of the structure in there? In the bug I am thinking of two separate lists of members were merged together into a single list.

Currently I am seeing this happen on one machine, and I am running some tests to see if I can reproduce it anywhere else. I have changed the structure from the test code slightly, to make its members more clear, and I am seeing this:



but I would like to know why I am getting this today, but I was getting a different effect yesterday *sigh*

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

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 01 2007 :  2:08:11 PM  Show Profile  Reply with Quote
I am now able to reproduce this on demand, especially after simplifying the test code a bit. For me the members of the structure are listed, but they are mixed in with these extra, unwanted items. So this is something.

case=961

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

khb
Tomato Guru

Germany
337 Posts

Posted - Feb 02 2007 :  02:38:17 AM  Show Profile  Reply with Quote
I'm glad that you can reproduce this. But I don't get a mixed list. I just have the six entries you have when you leave out the variables from your myStruct. And I'm getting this suggestions for all occurrences where I access my vector. Thus, I'm really looking forward to a fix of this problem

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 02 2007 :  12:53:21 PM  Show Profile  Reply with Quote
*sigh* that suggests we are still seeing different behaviour on different machines. If you email me via the forum I can reply with my test project attached. Would you be able to open it on your machine and see what behaviour you get?

The forum will not allow me to email you directly with an attachment.

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

khb
Tomato Guru

Germany
337 Posts

Posted - Feb 07 2007 :  01:28:29 AM  Show Profile  Reply with Quote
I sent you an email two days ago. If you didn't receive it, please tell me.

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 07 2007 :  08:57:50 AM  Show Profile  Reply with Quote
*sigh* my reply email is listed as sent at 13:41 on 6th Feb 2007
That will be England time, but you should have received it by now.

Lets try something else:

http://forum.wholetomato.com/colin/forumimages/array_suggest.zip

If this works then you will be able to download the zip I emailed you from that link.

This is my VC6 test project. The tests are being done in the file "array_suggest.cpp", and I have added comments to indicate the three lines where I am typing the dot, to see what happens.

While it would be nice if you see the same thing that I see, I am not sure if that is actually going to happen. At least this way we know we are testing on the same source code

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

khb
Tomato Guru

Germany
337 Posts

Posted - Feb 08 2007 :  02:37:07 AM  Show Profile  Reply with Quote
Hi feline,

finally, I got your mail. I'm sorry for the delay, this was my fault (a combination of looking to the wrong email account and an overeager filtering mechanism *pain*). I did all three tests on your project. In all three cases I get no suggestion when only typing the dot. If I press Ctrl+Space after the dot, then I get suggestions. In all three cases I get the list you included in your post from Feb 01 2007 : 12:31:05 PM, but there is a difference. On the fist and the third test (m_myVector[0] and foo[0]) I get exactly the list mentioned above. On the second test (foo.back()) I get the list, too, but everything except for feline_int and feline_double are shown in bold.

I hope this is of any help for you.

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 08 2007 :  09:56:54 AM  Show Profile  Reply with Quote
Email, a wonderful idea when it works well, but it does not always work so well *sigh*

For test 2 I am also getting most of the items shown in bold, so that bit is the same. The fact you have to press CTRL-SPACE to see the list suggests some difference if your IDE configuration. Do you have:

VA Options -> Text Editor -> C/C++ 6.0 -> Auto list members

turned on? This is turned on for me.

Apart from the renaming to make things more clear this should be the very same code you posted earlier in this thread. You should be seeing the same merged lists when you test this in your own test project. I am wondering if there are actually two separate bugs at work here.

If you copy / paste the code from my test project into your test project do you get the merged list, or just the list without the structure members?

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

khb
Tomato Guru

Germany
337 Posts

Posted - Feb 08 2007 :  10:38:45 AM  Show Profile  Reply with Quote
Hi feline,

I have all VA Options -> Text Editor -> C/C++ 6.0 -> Statement completion options on. Concerning my test project: I added the code to the file of my real application where the array makes the problems. Therefore, I just pasted your code to the file and I got different results. On the first test I don't get any suggestions after hitting Ctrl+Space. For the second test I get only the vector members in bold and for the third test I get them in normal font. This means, the variables feline_int and feline_double are not suggested at all. And as before, only typing the dot doesn't show a suggestion list box.

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 08 2007 :  11:49:13 AM  Show Profile  Reply with Quote
Do you normally see a listbox when you type a dot after something? Or do you always have to press CTRL-SPACE to trigger the listbox?

It seems that something is different in your real application, something that so far I have not been able to reproduce.

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

khb
Tomato Guru

Germany
337 Posts

Posted - Feb 09 2007 :  02:14:52 AM  Show Profile  Reply with Quote
When I type a dot after a member or local variable, then I never get a suggestion list. But hitting Ctrl+Space always shows the correct list. But I have a member which is a pointer to a struct. If I type a dot, then it is converted to "->" and the correct list is shown. But when I type "->" instead of the dot by myself, then I don't get a suggestion list automatically. And I have an instantiation of a struct that has a constructor. For this variable I don't even get a suggestion list after hitting Ctrl+Space. I removed the constructor, but that didn't help. By the way, the array I'm having the problem with contains a struct that also has a constructor, but this doesn't seem to be the problem. As I already mentioned before, I'm having an MFC application. And my files are write protected due to our version control system. But I guess this shouldn't be the problem, too, because it already worked with the versions before. That are the only differences that come to my mind. Is there anything else I could try?

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 09 2007 :  08:31:19 AM  Show Profile  Reply with Quote
Has VA always worked like this for you? So far I cannot reproduce this behaviour.

using VC6 and VA 1544 I have added the two lines:

std::string strName;
strName|


to a function. When I type the dot I always get a completion listbox automatically. This is with:

VA Options -> Text Editor -> C/C++ 6.0 -> Auto list members = ON
VC6 tools menu -> Options -> Editor tab -> Auto list members = OFF

with VA active the IDE option for auto list members has no effect. If I disable VA then this option works as expected. When it is turned off no listbox appears until I press CTRL-SPACE. When it is turned on the listbox appears automatically when I type the dot.

The fact the files are read only should not matter, so long as VA can read them.

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

khb
Tomato Guru

Germany
337 Posts

Posted - Feb 12 2007 :  03:06:42 AM  Show Profile  Reply with Quote
Yes, VA worked for me very well some time ago. I used VA already for creating the code I now have problems with. I wrote the code last year and touched it last month again. But, another thing has changed since then. I installed VS2005 on my machine, too. So I now have VC6 and VS2005 installed. I have exactly the settings you have. But even then "strName" thing doesn't work for me (I have to always hit Ctrl+Space), neither in my real application nor if I put it in the main function of the test project I received from you.

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 12 2007 :  08:36:34 AM  Show Profile  Reply with Quote
Have you reinstalled VA since installing VS2005? I assume you must have, to have VA working inside VS2005.

I am testing on a machine with VC6, VS2003 and VS2005 all installed, the extra IDE's should not matter, at least on paper.

If you turn on VAView does the HCB show the correct information for classes? I am wondering if VA is having more general problems.

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

khb
Tomato Guru

Germany
337 Posts

Posted - Feb 13 2007 :  02:29:04 AM  Show Profile  Reply with Quote
Yes, I reinstalled VA. Regarding the HCB, assume I have this line: m_myVec[i].x. If I hover over m_myVec, it is shown in the tree as member of my class, which is correct. I also get a correct tooltip. If I hover over i, then the HCB is empty, but the type of the index i (local variable) is shown in a tooltip. If I hover over ], the HCB is empty again, but the tooltip shows const_reference operator[](size_type _P). BUT: I managed it twice (out of ~50 times) that the []-operator was shown in the HCB. After the first time this happend, pressing Ctrl+Space after the dot stopped working. And if I hover over x, then the HCB doesn't change (previous content is retained) and no tooltip is shown at all.

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 13 2007 :  07:52:11 AM  Show Profile  Reply with Quote
I was actually thinking about any class / type, since if there is no information in the HCB then this would suggest that VA is not really parsing your code, so it has nothing to offer when you type the dot. Under these conditions it makes sense to have to press CTRL-SPACE to produce a listbox. However the fact you are seeing information in the HCB seems to rule out this theory.

Can you please export your VA settings:

VA Options -> Performance -> General -> Export Settings

and send me the resulting reg file? This way I can import them here on a test system and see if this makes any difference.

The developers are looking into the wrong items being listed, but since you are still seeing slightly different behaviour to me I am not sure how helpful that fix will be *sigh*

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

khb
Tomato Guru

Germany
337 Posts

Posted - Feb 13 2007 :  08:10:39 AM  Show Profile  Reply with Quote
I can't access to my private email account right now, so I sent in the settings file via the "Request Assistance" form. I hope you can get it from there.

Regards,
Marcus.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Feb 13 2007 :  11:56:00 AM  Show Profile  Reply with Quote
I have the registry file, many thanks for that. I am seeing the same effect, where typing dot does not produce a listbox. After a bit of fiddling I have found the cause. Turn on:

VA Options -> Text Editor -> listboxes -> Get content from default Intellisense

When this is turned off you have to press CTRL-SPACE to see the listbox. So this is actually unrelated to the problem with the content of the listboxes.

When "Get content from default Intellisense" is turned on I would have expected VA to respect the option:

VA Options -> Text Editor -> C/C++ 6.0 -> Auto list members

but this is having no effect, so I have put in a case for this:

case=5059

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