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
 Pointer to function typedefs
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

beylevem
Tomato Guru

102 Posts

Posted - Aug 20 2009 :  3:58:32 PM  Show Profile  Reply with Quote
If I have a typedef

typedef void (*PtrToFn)();

and I then try to use it by typing

PtrT(tab) - i.e. completion,

I get

PtrToFn()

i.e. redundant/incorrect parentheses

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Aug 20 2009 :  6:00:46 PM  Show Profile  Reply with Quote
I am confused. From memory you need to put brackets on the end when calling a function pointer, so it is reasonable for VA to add the backets. Am I missing something obvious here?

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

beylevem
Tomato Guru

102 Posts

Posted - Aug 21 2009 :  09:11:17 AM  Show Profile  Reply with Quote
We are talking about the typedef, not the variable. To expand my example:

typedef void (*PtrToFn)();
PtrToFn aPtr = &someFn;
aPtr();

Note that this is not a pointer to member function, just a pointer to function. Also, with pointer to function, one can write either

aPtr() or (*aPtr)()

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Aug 21 2009 :  12:03:17 PM  Show Profile  Reply with Quote
This makes sense, and I remember these two syntaxes for calling the function. But simply taking the "aPtr()" syntax, why would you want to write "aPtr" and not add the brackets?

When I write a function name in my code then 99.999% of the time I want the brackets on the end since I am calling the function. Am I still missing something obvious?

Off hand the only reason I can see for not wanting the brackets is if you are writing the if statement in:

if(NULL <> aPtr)
{
    aPtr();
}

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

beylevem
Tomato Guru

102 Posts

Posted - Aug 21 2009 :  1:44:04 PM  Show Profile  Reply with Quote
You're still missing the point. The problem is not with

aPtr() i.e. aP(tab) ==> aPtr()

but with

PtrT(tab) i.e. PtrT(tab) ==> PtrToFn()

The paretheses should not be added when the typedef is used
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Aug 24 2009 :  1:33:23 PM  Show Profile  Reply with Quote
*ah* yes, this makes sense. I thought there had to be confusion going on here

Can you try VA 1731? So far I cannot reproduce this problem with this new build, which does contain some fixes for brackets being appended when accepting listboxes.

http://www.wholetomato.com/downloads/default.asp

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

beylevem
Tomato Guru

102 Posts

Posted - Aug 25 2009 :  09:29:13 AM  Show Profile  Reply with Quote
Unfortunately, 1731 does not fix the problem for me. I opened a new instance of VS2008, added a header file, and typed

class C1 {
typedef bool (*chgFnPtr)(C1*, int);
chgFnPtr()
};

As soon as I do the second chg(tab), VA adds the parentheses.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Aug 25 2009 :  2:35:00 PM  Show Profile  Reply with Quote
I am seeing the same problem now:

case=31476

I had simplified the test a bit to much, and was testing this with the typedef inside a function, and the problem does not show up under those conditions. Oops

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