Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!ncar!gatech!rutgers!bellcore!faline!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP Newsgroups: comp.lang.c Subject: Re: varargs question Keywords:Message-ID: <8045@alice.UUCP> Date: 16 Jul 88 00:28:39 GMT References: <161@neti1.uucp> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 26 In article <161@neti1.uucp>, bdr@neti1.UUCP writes: > I am writing a function which, ideally, would take an optional > argument which would be a pointer to a function which returns a > pointer to a char. I am using a non-ansi type compiler. > My code looks something like: > char *(*func)(); /* local variable to hold pointer */ ... > func = va_arg(ap, char *(*)()); > Unfortunately, va_arg turns the cast into something like: > (char *(*)() *) ... > instead of the desired: > (char *(**)() ) ... Yes indeed. Sorry about that -- the preprocessor is awfully literal-minded. Do it this way: typedef *(*MYPTR)(); ... MYPTR func; ... func = va_arg(ap,MYPTR);