Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Pointer to function typedefs

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
beylevem Posted - Aug 20 2009 : 3:58:32 PM
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
7   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Aug 25 2009 : 2:35:00 PM
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
beylevem Posted - Aug 25 2009 : 09:29:13 AM
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.
feline Posted - Aug 24 2009 : 1:33:23 PM
*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
beylevem Posted - Aug 21 2009 : 1:44:04 PM
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
feline Posted - Aug 21 2009 : 12:03:17 PM
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();
}
beylevem Posted - Aug 21 2009 : 09:11:17 AM
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)()

feline Posted - Aug 20 2009 : 6:00:46 PM
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?

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000