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
 Newbie question on overloaded functions
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

jkuzeja
New Member

USA
4 Posts

Posted - Jan 20 2005 :  4:13:22 PM  Show Profile
I have just installed the trial version of the software, and am hoping to use it to bypass some serious IntelliSense bugs (i.e., functions declared in anonymous namespaces are really messed up.) Quite quickly, however, I ran into a problem so obvious and so severe that I am sure I must be doing something wrong.

It seems like VA_X 1293 is not handling overloaded functions (in C++) correctly. Here is the example code:


void foobar (int x) {
	x = x;
}

int foobar (double x) {
	x = x;
	return 0;
}

int foobar (float x) {
	x = x;
	return 0;
}

int main (int argc, char **argv) {
	foobar (1);
	foobar (2.0f);
	foobar (3.0);
	return 0;
}


(The calls to foobar are not really needed, but I saw some other posts that mentioned that functions have to be referenced sometimes, so I threw them in.)

What happens is that if I hover over any instance of the symbol foobar, I get exactly the same prototype, namely the first prototype encounted - void foobar (int x). I do not get "[1 of 3]" or up and down arrows in the tooltip. If I turn "get content from default Intellisense" on, then I do get all three versions of foobar (eventually - the second time I hover over a given instance of a symbol,) but that sort of defeats the purpose of getting VA.

I've tried all of the options I can think of, but no luck. Any advice would be welcome - this is sort of a showstopper for me. If this isn't a sufficient description, I can try to post screenshots later, but that seems like overkill right now.

-Jim




Here's some other relevant info:

No plugins added to DevEnv.

VA_X.dll file version 10.1.1293.0
Licensed to:
VA X:
VA.NET 7.1:
VAOpsWin.dll version 1.2.0.4
DevEnv.exe version 7.10.3077.0
msenv.dll version 7.10.3077.0
Font: Courier New 13(Pixels)
Comctl32.dll version 5.81.4916.400
WindowsNT 5.0 Build 2195 Service Pack 4
2 processors

Platform: Win32
Stable Includes:
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\include;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\atlmfc\\include;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\PlatformSDK\\include\\prerelease;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\PlatformSDK\\include;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\SDK\\v1.1\\include;

Library Includes:
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\atlmfc\\src\\mfc;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\atlmfc\\src\\atl;
C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\crt\\src;

Other Includes:



Microsoft Visual C++ .NET 69586-335-0000007-18943
Microsoft Development Environment 2003 Version 7.1.3088
Micorsoft .Net Framework 1.1 Version 1.1.4322 SP1


OS Name Microsoft Windows 2000 Professional
Version 5.0.2195 Service Pack 4 Build 2195
OS Manufacturer Microsoft Corporation
System Name FRUGUE
System Manufacturer INTEL_
System Model D865PERL
System Type X86-based PC
Processor x86 Family 15 Model 3 Stepping 3 GenuineIntel ~2792 Mhz
Processor x86 Family 15 Model 3 Stepping 3 GenuineIntel ~2792 Mhz
BIOS Version BIOS Date: 01/22/04 10:36:47 Ver: 08.00.10
Windows Directory C:\\WINNT
System Directory C:\\WINNT\\system32
Boot Device \\Device\\Harddisk0\\Partition1
Locale United States
User Name FRUGUE\\jkuzeja
Time Zone Eastern Standard Time
Total Physical Memory 1,571,504 KB
Available Physical Memory 859,896 KB
Total Virtual Memory 5,630,908 KB
Available Virtual Memory 4,254,004 KB
Page File Space 4,059,404 KB
Page File C:\\pagefile.sys

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Jan 24 2005 :  1:48:13 PM  Show Profile
i am seeing the same problem you are seeing, and i am surprised, since normally VAX handles overloaded functions far more successfully than this.

first the good news
using .NET 2003 my (default) text editor toolbar contains a button to display the quick info on a function, which is bound (again by default) to CTRL_K + CTRL_I

place the caret inside the function call and either press the button, or use the keyboard shortcut key. this will show this IDE tooltip with all of the function overloads, along with the parameter info.

if i place all three overloaded foobar functions into the same class in a header file, and simply put class_name:: in front of the function names where these are defined then the tooltips now work as expected.

do you normally use a lot of overloaded functions that are not class member functions? i am just wondering how common a problem this is for you.

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

jkuzeja
New Member

USA
4 Posts

Posted - Jan 24 2005 :  7:32:14 PM  Show Profile
quote:
do you normally use a lot of overloaded functions that are not class member functions? i am just wondering how common a problem this is for you.


Well, I simplified the example to the bare essentials. What actually was happening in the code was that I was avoiding macros by declaring a few convenience functions inside of an anonymous namespace. The anonymous namespace brought out the Microsoft Intellisense bug; the overloading of the function names brought out the VAX "feature".

I had already discovered the workaround you proposed; however, the Microsoft Intellisense bug with anonymous namespaces renders that useless. (The MS bug is that once you call a function defined in an anonymous namespace, ALL Intellisense info is gone, gone, gone from the point of that call onward. Adding a name to the namespace "fixes" this - but of course pollutes the global namespace namespace, defeating the purpose of anonymous namespaces in preference to good old fashioned "static" functions. I could also use a GUID as the namespace name, but I really, really do not want to - and all of this is besides the point as far as VAX is concerned.)

I could avoid the issue as well by avoiding top level function overloading, but since it is certainly allowed by the language, this is not a great solution. And there's always the issue of existing code.

Here's my code snippet, showing that this did in fact occur in production code:

namespace {
	void foo (int x) {
		x = x;
	}

	int foo (double x) {
		x = x;
		return 0;
	}

	void setChannelParams (ChannelDescArray &cda, int channel, const string ¶ms) {
		ChannelDesc &cd = cda.getChannel (channel);
		cd.setParams (params);
	}
	
	string getChannelParams (const ChannelDescArray &cda, int channel) {
		const ChannelDesc &cd = cda.getChannel (channel);
		string params = cd.getParams ();
		return params.empty () ? "0" : params;
	}
	
	void setChannelParams (ProfileDesc &pd, int channel, const string ¶ms) {
		setChannelParams (pd.getChannelDescArray (), channel, params);
	}
	
	string getChannelParams (const ProfileDesc &pd, int channel) {
		return getChannelParams (pd.getChannelDescArray (), channel);
	}
}

I left the artificial "foo" functions in there just to illustrate that the same problem I alluded to in the original post applies to "top level" functions within namespaces. Furthermore, the namespace doesn't have to be anonymous for VAX to have problems with the overloads. Just to be very clear:

namespace /* XXX */ {      // fails either way
	void foobar (int x) {
		x = x;
	}

	int foobar (double x) {
		x = x;
		return 0;
	}

	int foobar (float x) {
		x = x;
		return 0;
	}
}
// using namespace XXX;		// uncomment this if necessary

int main (int argc, char **argv) {
	foobar (1);
	foobar (2.0f);
	foobar (3.0);
	return 0;
}

will have the same problems as the original example.

To answer the original question: It is not that unusual for me to have top level functions for stateless algorithmic code - I don't subscribe to the "everything must be a class" school. And if two functions have similar purposes and can be distinguished by their signatures, I may well overload them.



I would like to get more feedback on this issue. Please feel free to mod this up and perhaps get rid of "newbie" out of the subject if you feel that it is warranted. Thanks.

-Jim
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Jan 30 2005 :  5:46:31 PM  Show Profile
apologies for the delay in getting back to you, i have been grappling with the tail end of the flu, which isn't helping *sigh*

still i am getting over it, and now i am catching up on things

in this case, due to my many years as a C programmer i would have just made these static functions, rather than placing then in an unnamed namespace. i am still catching up with namespaces, how and when to use them, so it is very interesting to see how you are using them here.

also, this is definitely a VAX bug. i was wondering if it was very rare, so it could be ignored. on reflection probably best to see if this can be fixed

case=495

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

jkuzeja
New Member

USA
4 Posts

Posted - Feb 01 2005 :  2:16:43 PM  Show Profile
Thanks. I sometimes wonder if I am shooting myself in the foot by trying to use "the newfangled stuff", but hey, it's there, and if I don't use it, someone else will.

-Jim
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Feb 01 2005 :  3:54:07 PM  Show Profile
LOL very true

as a perhaps rather ugly work around you could replace the namespace with a class, and make all of the functions public members. this will hide the functions, and VAX seems much happier with classes than "raw" functions.

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

jkuzeja
New Member

USA
4 Posts

Posted - Feb 03 2005 :  7:20:58 PM  Show Profile
Thanks for the suggestion. However, I think I'll live with the lack of correct tooltips for a while rather than ugly up the code. My options seem to be:

1) Do nothing - "T foo (X x, Y y) {}", "static T foo (X x, Y y) {}" or "namespace { T foo (X x, Y y) {} }" - VAX prototypes will be wrong. Calls look like "foo (x, y);"

2) use "class Dummy { public: T foo (X x, Y y) {} }" - very ugly - call calls must change, and there needs to be a dummy object of class Dummy that is not actually accessed. Calls look like "d.foo (x, y);"

3) Use "class Dummy { public: static T foo (X x, Y y) {} }" - ugly, but VAX will work. (Or not.... see below) All calls must change to "Dummy::foo (x, y)"

4) Use "struct Dummy { static T foo (X x, Y y) {} }" - pretty much just as ugly as 3, and a little obscure to boot (not everyone is aware that structs and classes are the same thing, except with different default access.) Not sure VAX handles this...

Actually, here's some more code - VAX doesn't seem to handle ANY of these overloads:




void foobar (int x) {
	x = x;
}

int foobar (double x) {
	x = x;
	return 0;
}

int foobar (float x) {
	x = x;
	return 0;
}

struct DummyStruct {
	void foobar (int x) {
		x = x;
	}

	int foobar (double x) {
		x = x;
		return 0;
	}

	int foobar (float x) {
		x = x;
		return 0;
	}
} ds;

class DummyClass {
public:
	void foobar (int x) {
		x = x;
	}

	int foobar (double x) {
		x = x;
		return 0;
	}

	int foobar (float x) {
		x = x;
		return 0;
	}
} dc;

struct DummyS {
	static void foobar (int x) {
		x = x;
	}

	static int foobar (double x) {
		x = x;
		return 0;
	}

	static int foobar (float x) {
		x = x;
		return 0;
	}
};

struct DummyC {
public:
	static void foobar (int x) {
		x = x;
	}

	static int foobar (double x) {
		x = x;
		return 0;
	}

	static int foobar (float x) {
		x = x;
		return 0;
	}
};

int main (int argc, char **argv) {
	foobar (1);
	foobar (2.0f);
	foobar (3.0);
	ds.foobar (1);
	ds.foobar (2.0f);
	ds.foobar (3.0);
	dc.foobar (1);
	dc.foobar (2.0f);
	dc.foobar (3.0);
	DummyS::foobar (1);
	DummyS::foobar (2.0f);
	DummyS::foobar (3.0);
	DummyC::foobar (1);
	DummyC::foobar (2.0f);
	DummyC::foobar (3.0);

	return 0;
}



On my machine, at least, in none of the cases above do I get anything other than the first overloaded function in the tooltip. VAX does detect which namespace it is in - that is, the d.foobar and dc.foorbar calls are correctly identified as coming from DummyStruct and DummyClass, respectively, but the overloading is not reported.

-Jim
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Feb 08 2005 :  5:17:53 PM  Show Profile
reproduced. it has taken some digging, but i now know why. i reduced this right down to a really simple case, and i still had this problem. it turns out you need to place the class definition in a .h file before VAX will report the member function overloads in its tooltips.

yet another reason not to place these functions into a class, at least not in your case

case=502

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