Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Possible to use varags with member-function pointers?

Reply
Thread Tools

Possible to use varags with member-function pointers?

 
 
John Silicon
Guest
Posts: n/a
 
      07-29-2003
Has anyone ever successfully implimented passing member-functions to a
varargs function? I thought it would be fairly straight-forward, but seems
to come up with nice syntax errors. I've checked my code for syntax errors,
so it must be something with my code effecting the code returned by the
va_arg macro.

I'm implimenting a recursive-decent parser, and I need to make a varargs
function that is passed a variable number of productions owned by the same
class, terminated by a NULL.
The function-pointers are of type "CNode* (CParser::*)(CTokenList*)"
Here's my code:
CNode* do_order(CNode* topLevelNode, CTokenList* toklist) {
va_list args;
va_start(toklist);
while (1) {
production = va_arg(args, CNode* (CParser::*)(CTokenList*));
if (production == NULL) break;
topLevelNode -> pushchild(this->*production(toklist));
}
va_end(args);
return topLevelNode;
}

But, this produces the error:
Parser.cpp(92): syntax error : ')'

Line 92 is the line with va_arg() on it.



 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-29-2003
"John Silicon" <(E-Mail Removed)> wrote...
> Has anyone ever successfully implimented passing member-functions to a
> varargs function? I thought it would be fairly straight-forward, but

seems
> to come up with nice syntax errors. I've checked my code for syntax

errors,
> so it must be something with my code effecting the code returned by the
> va_arg macro.
>
> I'm implimenting a recursive-decent parser, and I need to make a varargs
> function that is passed a variable number of productions owned by the same
> class, terminated by a NULL.
> The function-pointers are of type "CNode* (CParser::*)(CTokenList*)"
> Here's my code:
> CNode* do_order(CNode* topLevelNode, CTokenList* toklist) {


Don't you need to have ellipsis here

do_order(blah toklist, ...) {
^^^^

???

> va_list args;
> va_start(toklist);
> while (1) {
> production = va_arg(args, CNode* (CParser::*)(CTokenList*));
> if (production == NULL) break;
> topLevelNode -> pushchild(this->*production(toklist));


I think this has to be

topLevelNode->pushchild((this->*production)(toklist));

> }
> va_end(args);
> return topLevelNode;
> }
>
> But, this produces the error:
> Parser.cpp(92): syntax error : ')'
>
> Line 92 is the line with va_arg() on it.


I am not sure how ellipsis and va_*** macros should behave when
used with pointers to members, but suspect that they won't work.
pointers to members are not built-in types.

Victor


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
efficient data loading with Python, is that possible possible? igor.tatarinov@gmail.com Python 10 12-14-2007 04:44 PM
is it possible to possible to create an iterator from a callback interace? aninnymouse@gmail.com C Programming 4 02-21-2006 02:10 PM
XML + XSD: Is it possible to get all possible Values for an Element? Markus Java 1 11-22-2005 02:51 PM
is it possible to use a cisco 1721 as a vpn terminator smokey Cisco 1 11-28-2004 12:26 AM
Possible to use a route other than the default fo cisco vpn client? William Schwartz Cisco 0 10-27-2004 05:19 PM



Advertisments