C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Possible to use varags with member-function pointers?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
John Silicon
Guest





PostPosted: Tue Jul 29, 2003 8:12 am    Post subject: Possible to use varags with member-function pointers? Reply with quote



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.



Back to top
Victor Bazarov
Guest





PostPosted: Tue Jul 29, 2003 1:34 pm    Post subject: Re: Possible to use varags with member-function pointers? Reply with quote



"John Silicon" <jsilicon (AT) earthlink (DOT) net> wrote...
Quote:
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, ...) {
^^^^

???

Quote:
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));

Quote:
}
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



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.