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
 FindReference of a static function or variable
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

xMRi
Tomato Guru

Germany
315 Posts

Posted - Jan 18 2017 :  04:53:49 AM  Show Profile  Reply with Quote
When I am in a source module and I have a static function in this module, than this function can only be used and "referenced" in this module.

I.E.:
static CString Foo(PCTSTR pszText);


But the "Find Reference" function searches other files too and will find also member functions. Even if the function is declared outside of a class. So also member functions should never be found.



Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Jan 18 2017 :  05:41:33 AM  Show Profile  Reply with Quote
When member functions are being picked up, are these static member functions or just "normal" member functions? So far, doing some simple tests, I cannot get Find References to return both the static free function and a class member function with the same name. I am working with a few variations on the following test code. This code in the .h file:

static int staticMemberAndFreeTest(int nTestSize);

class testingStaticFindRefScope
{
	void simpleMember();
	int staticMemberAndFreeTest(int nTestSize);
};

and this code in the matching .cpp file:

int staticMemberAndFreeTest(int nTestSize)
{
	return 0;
}


We are considering restricting the files checked by Find References for static functions, but have wondered if checking more widely would be helpful to detect duplicate names:

case=19660

But this does assume that Find References is behaving reasonably at the moment. It sounds like it isn't for you.

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

xMRi
Tomato Guru

Germany
315 Posts

Posted - Jan 18 2017 :  06:54:28 AM  Show Profile  Reply with Quote
Here you see the search for a function called GetName.
Its the first match onb line 111


Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming

Edited by - xMRi on Jan 18 2017 06:54:57 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Jan 18 2017 :  07:22:36 AM  Show Profile  Reply with Quote
Dropbox is being a little tricky about showing me the image, so for easy reference here it is again:



Thank you for this, clearly my test code is not testing quite the right thing.

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

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Jan 18 2017 :  7:27:41 PM  Show Profile  Reply with Quote
When this happens, are you triggering Find References on an instance of the static function, or on the class member function?

If you are doing the find on the static function, can you please trigger a Find References on the class member function "GetName()" and see how many references are found? Are the same, problem, references being found?

So far I cannot reproduce this problem, even getting a function to return a pointer to the class holding the duplicate function name, as shown in your screen shot. So I am wondering what I am missing about the code.

If you jump to one of the incorrect references, and place the caret into "GetName", what does VA show in the context and definition field? What happens when you press Alt-G?

I am wondering if the problem is limited to Find References, or if it will show up in other ways as well. I am also wondering if all references to GetName are being found, or only some references. If it is only some references, then perhaps there is a pattern to help explain this.

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

xMRi
Tomato Guru

Germany
315 Posts

Posted - Jan 19 2017 :  12:26:00 PM  Show Profile  Reply with Quote
1. I am searching for the static GetName function in this module
2. Some of the Other GetName functions seam to be part of templates.

Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Jan 19 2017 :  3:41:45 PM  Show Profile  Reply with Quote
I am still not seeing any problems here. In your screen shot, are any of the references in the first file wrong? I am assuming all of the references in the other files are wrong, but what about this?

Do you have calls to a different "GetName" function in the first file, that VA is correctly filtering out?

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

xMRi
Tomato Guru

Germany
315 Posts

Posted - Jan 20 2017 :  01:18:12 AM  Show Profile  Reply with Quote
The first file and list is correct.

The matches below doesn't make sense.
It was a static function in a CPP module.

Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Jan 20 2017 :  3:46:16 PM  Show Profile  Reply with Quote
If you re-run the find references from the screen shot, do you still get the wrong results listed?

Would you be able to send me just the files that are showing these results, purely for testing purposes? I realise this is often not at all possible, but it's worth asking on the off chance it is possible. I could then try to reproduce this problem here with the same files, and if I can reproduce it, try to find out what is triggering this problem. If this is possible, please submit the files via the form:

http://www.wholetomato.com/support/contact.asp

including this thread ID or URL in the description, so we can match it up.

Alternatively, if you have the time, could you please try making a new dummy project, just adding these 4 files to it, and then doing a Find References in the dummy project, and see if Find References still lists the extra, incorrect references.

When you say "module", what do you mean? Is this a separate project in the solution? Or just a set of files that don't reference any other files in the solution? I am wondering if the "module" boundaries are obvious to the IDE / VA, or if they are more "we know they are here, but they are not explicitly stated".

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

xMRi
Tomato Guru

Germany
315 Posts

Posted - Jan 24 2017 :  07:22:12 AM  Show Profile  Reply with Quote
I just used a small program. Cut some source parts and sent the resulting (not compiling version) to your support.
You can repro the problem there.

Thanks for your always perfect support!

Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Jan 24 2017 :  11:49:19 AM  Show Profile  Reply with Quote
I have the test project, many thanks, I am looking at it now.

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:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000