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
 global friend functions ignored ?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

jonnygarrett
New Member

8 Posts

Posted - Dec 13 2004 :  3:09:33 PM  Show Profile
hi

it seems that friend functions are not added to the completion listbox unless specifically referenced through the class - eg.

class myclass
{
void func (int a, int b);
friend void otherfunc(int a);
};

myclass test;


typing "test." opens a listbox showing func and otherfunc - it'd be nice if also typing "otherfunc" would also show the prototype

I have seen a couple of posts regarding friends, but they either didn't seem to be this exact issue, or there was no resolution to the issue

thanks for any help

Jonathan





VA_X.dll file version 10.1.1289.0
VAOpsWin.dll version 1.2.0.4
MSDev.exe version 6.0.9782.0
Devshl.dll version 6.0.9782.0
Devedit.pkg version 6.0.9782.0
Font: Courier -13(Pixels)
Comctl32.dll version 5.82.2800.1106
WindowsNT 5.1 Build 2600 Service Pack 1
4 processors



forgot this bit

Licensed to:
VA X:
VA 6.0: [email protected] (5-user license)

Edited by - jonnygarrett on Dec 13 2004 7:29:05 PM

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Dec 15 2004 :  6:12:41 PM  Show Profile
i have tried this in both VC6 and .NET 2003, using VAX 1287

in both cases i see the prototype of "otherfunc" just fine.

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

Sam C
New Member

4 Posts

Posted - Dec 16 2004 :  2:13:55 PM  Show Profile
I'm on 1289 and I see the bug.. Was it possibly not an issue in 1287 and broken in 1289?
Go to Top of Page

jonnygarrett
New Member

8 Posts

Posted - Dec 16 2004 :  2:14:36 PM  Show Profile
I'm not sure if I explained this properly - typing "test." shows the two prototypes fine, but typing *just* "otherfunc" doesn't show it's prototype as if it were a global function

Jonathan
Go to Top of Page

jpizzi
Tomato Guru

USA
642 Posts

Posted - Dec 19 2004 :  12:15:27 AM  Show Profile
Has otherfunc been declared (or defined) prior to the attempt to get it to appear in the listbox?
Haven't a clue if this is related to the problem or not... Just guessing.

Joe Pizzi
Go to Top of Page

jonnygarrett
New Member

8 Posts

Posted - Dec 20 2004 :  1:29:35 PM  Show Profile
it has been declared before being used, but not defined - the class declarations are in a project wide header - I think people should be able to include this header, and get "visual assisted" prototypes for all functions including friends

are other people not experiencing this issue ? - as sam mentions, could it be a problem with 1289 ?

thanks

Jonathan



quote:
Originally posted by jpizzi

Has otherfunc been declared (or defined) prior to the attempt to get it to appear in the listbox?
Haven't a clue if this is related to the problem or not... Just guessing.


Go to Top of Page

jpizzi
Tomato Guru

USA
642 Posts

Posted - Dec 20 2004 :  9:22:35 PM  Show Profile
Your original description suggests that VA cannot find the globally-declared function. When you add it as a friend to the class, it can then find it.

If you type otherfunc( 5 ) and click on the function name and click "Go," does VA take you to the definition or declaration? I am betting not. I think that the fact that it does show up when declared a friend to the class is a red-herring (in case you aren't familiar with the phrase, that means it is not related).

Look for things like VA not finding the header file.

Joe Pizzi
Go to Top of Page

Sam C
New Member

4 Posts

Posted - Dec 21 2004 :  1:48:50 PM  Show Profile
quote:
Originally posted by jpizzi

Your original description suggests that VA cannot find the globally-declared function. When you add it as a friend to the class, it can then find it.



What the hell are you talking about? His original description is this:

"it seems that friend functions are not added to the completion listbox unless specifically referenced through the class"

And then he goes on to give an example. The problem is that a friend function, even if declared in a class, should be globally scoped but VAX isn't picking it up in the global scope--you have to explicitly reference it through the class to get it to show up in the list box.

Did you try his example? It was quite easy for me to reproduce.

I don't think this problem has anything to do with VAX not picking up a header. In my test, everything was in the same file... all i did was this in one cpp file:

class foo
{
friend void bar(int baz);
};


void jojo()
{
bar(); // when you type this VAX doesn't put bar in the listbox
}


Then if you move the declaration of bar outside the class like this, it works:


void bar(int baz);


class foo
{
friend void bar(int baz);
};


void jojo()
{
bar(); // VAX will now put bar() in the listbox when you type this
}


Are you seeing other behavior than this? Can you tell me the version you are using?


-sam

Go to Top of Page

jonnygarrett
New Member

8 Posts

Posted - Dec 21 2004 :  1:52:17 PM  Show Profile
hi Joe

my problem is that "otherfunc" is only shown in the completion box if it's either explicitly referenced through something of type myclass (ie. myclass test; test.other...) or if it's pulled out of the class and declared as a global function (aren't friend functions also global, but with access rights to the class ?)

the following code illustrates the issue (it still happens if it's in the same file)

class myclass
{
void func (int a, int b);
friend void otherfunc(int a);
};

void blah(void)
{
myclass test;

test. <- 1
other <- 2
}

at 1, I am presented with a selection box showing "func" and "otherfunc"

at 2, I am not presented with anything showing me "otherfunc" as I expect

if, however, I move "otherfunc" out of the class (which isn't a real option as I need it to have friend access), it'll show up in the selection box

if you have a spare minute, could you paste the above code into a cpp file and see if you get the same behavior ?

thanks

Jonathan



quote:
Originally posted by jpizzi

Your original description suggests that VA cannot find the globally-declared function. When you add it as a friend to the class, it can then find it.

If you type otherfunc( 5 ) and click on the function name and click "Go," does VA take you to the definition or declaration? I am betting not. I think that the fact that it does show up when declared a friend to the class is a red-herring (in case you aren't familiar with the phrase, that means it is not related).

Look for things like VA not finding the header file.


Go to Top of Page

jpizzi
Tomato Guru

USA
642 Posts

Posted - Dec 21 2004 :  6:19:28 PM  Show Profile
quote:
What the hell are you talking about? His original description is this:


Back off. What I am saying is that the statement,
friend void otherfunc(int a);
does not declare a function. At this point, otherfunc does not exist. The fact that VA gives information about the function when scoped within the class is actually a bug. The friend declaration does not make otherfunc a member of myclass.

So, what I am saying is that there is no function otherfunc. The fact that VA doesn't offer it as a suggestion is appropriate behavior. The fact that VA does offer it as a member is a bug.

Now, if there is a function otherfunc, and it is within scope (and visible, either through declaration in this file or through a #include) at this point, get rid of any mention to myclass and the friend declaration, and repost the code that is actually the problem.

Joe Pizzi
Go to Top of Page

Sam C
New Member

4 Posts

Posted - Dec 21 2004 :  8:14:07 PM  Show Profile

quote:
Originally posted by jpizzi
Back off. What I am saying is that the statement,
friend void otherfunc(int a);
does not declare a function. At this point, otherfunc does not exist. The fact that VA gives information about the function when scoped within the class is actually a bug. The friend declaration does not make otherfunc a member of myclass.



You're wrong about "friend" not declaring a function. Did you try the sample code I provided? Visual C++ is happy compiling the code, even if the only declaration of a function is inside the class as a "friend" function.

Try it yourself.. Stick this in a file and tell me if it doesn't compile for you, beacuse it does for me:


class foo
{
  friend void bar(int baz);
};


void jojo()
{
  bar(3);
}


I don't know what the C++ spec says specifically about this, but since VAX is a visual studio addon, I would expect that it applies the same rules to function declarations that the vc compiler does. For what it's worth, gcc has the same behavior.

-sam

Go to Top of Page

jpizzi
Tomato Guru

USA
642 Posts

Posted - Dec 21 2004 :  11:48:41 PM  Show Profile
Maybe it compiles. But, it can't link. Because there is no code for Bar.

You have to remember that VA does not have the luxury of a full syntax check. It can only do a cursory one, because people scroll so much when they edit.

Joe Pizzi
Go to Top of Page

Sam C
New Member

4 Posts

Posted - Dec 22 2004 :  1:36:37 PM  Show Profile
quote:
Originally posted by jpizzi

Maybe it compiles. But, it can't link. Because there is no code for Bar.

You have to remember that VA does not have the luxury of a full syntax check. It can only do a cursory one, because people scroll so much when they edit.




Are you kidding me? Go make a definition for bar in another file. Now it links and the VAX bug is still present.

Either you don't understand the issue here, or you're just being a complete jackass (in case you aren't familiar with the phrase, it refers to a foolish or stupid person; a blockhead: G?You've acted like an irrational jackass and it's time you stoppedG? (Margaret Truman).).

-sam

Go to Top of Page

Stephen
Tomato Guru

United Kingdom
781 Posts

Posted - Dec 22 2004 :  1:40:08 PM  Show Profile
Sam, please tone your language down. Thank you.

Stephen Turner
ClickTracks http://www.clicktracks.com/
Winner: ClickZ's Best Web Analytics Tool 2003 & 2004
Go to Top of Page

jpizzi
Tomato Guru

USA
642 Posts

Posted - Dec 22 2004 :  6:32:51 PM  Show Profile
From the Standard: "For a friend function declaration, if there is no prior declaration, the program is ill-formed." (11.4)

I'll let WT comment on whether they want to change their code to support something non-standard (which Microsoft could fix at any time, which then causes WT's code to be wrong).

Joe Pizzi
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Dec 23 2004 :  11:44:24 AM  Show Profile
quote:
Originally posted by Sam C

Are you kidding me? Go make a definition for bar in another file. Now it links and the VAX bug is still present.

Either you don't understand the issue here, or you're just being a complete ****


Sam, this sort of attitude is NOT helpful, or polite. people are trying to help, so please act accordingly. i am very tempted to edit your post and clean it up.

as a general point, it is often quite difficult and takes several rounds of question and answer for me to properly understand and reproduce some bug reports. sometimes this is down to different people using English differently, sometimes it is down to different machines behaving differently.

regardless of the reason staying calm and polite is the best way to get help.

with regard to the specific problem reported here, based on the code SAMPLE produced and the description the only VAX bug i am seeing is that it suggests a friend function from a "this" pointer.

while there is no definition of the function outside of the class i am not surprised VAX does not offer suggestions. i don't know the spec well enough to quote it, but the definition of otherfunc is definetly only present in the scope of the class.

the bottom line is that VAX is NOT a full blown compiler, instead it is trying to offer helpful and sensible suggestions based on changing code. so arguing over subtle points along the lines of "but the compiler understands it" does not get us very far.


Jonathan, is adding a definition of otherfunc outside of the class, in addition to declaring it a friend function an acceptable option for you? based on a quick and dirty test VAX understands this just fine, and it should still work the same way.

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

jonnygarrett
New Member

8 Posts

Posted - Dec 23 2004 :  1:41:16 PM  Show Profile
hi

in this case it's not really an option as the friends in question are part of an inline math library consisting of maybe 100 or so friend functions and around 200 member functions (spread over a few classes)

I agree that the fact the function is only declared in the class (and as a friend) does not meet the spec as regards specifying a prototype - but, as both the vc7 and gcc compilers support this type of prototype (I know we were trying not to say things like that!), and (especially in my case) declaring them as such can (in my opinion) simplify the code, it would be a benefit for vax to treat them as global functions

I know I'm grossly simplifying things, but it wouldn't seem too big a deal for it to add any friends it finds when parsing struct/class definitions to it's list of global functions

thanks for you reply

Jonathan



quote:
Originally posted by feline
Jonathan, is adding a definition of otherfunc outside of the class, in addition to declaring it a friend function an acceptable option for you? based on a quick and dirty test VAX understands this just fine, and it should still work the same way.

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Dec 23 2004 :  4:06:42 PM  Show Profile
given that two different compilers both allow this, and the situation you are describing you have convinced me to put in a case after all this is a little different to a one off special case somewhere in your code. it is now up to the developers to make a decision on this when they reach it.

case=476

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

jonnygarrett
New Member

8 Posts

Posted - Dec 23 2004 :  6:37:00 PM  Show Profile
great - thanks!



quote:
Originally posted by feline

given that two different compilers both allow this, and the situation you are describing you have convinced me to put in a case after all this is a little different to a one off special case somewhere in your code. it is now up to the developers to make a decision on this when they reach it.

case=476

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