Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!bobg+ From: bobg+@andrew.cmu.edu (Robert Steven Glickstein) Newsgroups: comp.lang.c Subject: Varargs problem Message-ID: <4YxPuc200VsnE_B3Jy@andrew.cmu.edu> Date: 25 Aug 89 21:48:24 GMT Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA Lines: 46 I wish to extract a variable of type "pointer to function returning int" [(int (*) ())] from a varargs parameter list, and I can't. My function looks like the usual: foo(va_alist) va_dcl { va_list ap; int (*fn)(); va_start(ap); fn = va_arg(ap, int (*) ()); va_end(ap); } The problem, at least in my OS's implementation, is that the va_arg macro is defined as # define va_arg(list,mode) \ ((mode *)((list += (sizeof(mode)+3)&(-4))\ -((sizeof(mode)<4)?sizeof(mode):\ (sizeof(mode)+3)&(-4))))[0] and a typecast operator like (int (*) ()) is turned into (int (*) () *) by the macro, on which the compiler barfs. I might be able to do fn = (int (*) ()) va_arg(ap, char *); but I don't know how portable this is, and I'd like to do this in a highly portable fashion. Any suggestions? _______________________________ Bob Glickstein, System Designer Information Technology Center room 220 Carnegie Mellon University Pittsburgh, PA 15213-3890 (412) 268-6743 Internet: bobg+@andrew.cmu.edu UUCP: ...!harvard!andrew.cmu.edu!bobg A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others. -- Ambrose Bierce, "The Devil's Dictionary"