Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!uunet!etnibsd!sean From: sean@etnibsd.UUCP (Sean McElroy) Newsgroups: comp.lang.c Subject: How do you build a varargs argument list? Keywords: stdarg.h varargs(3) variable length argument list standard Message-ID: <1070@etnibsd.UUCP> Date: 9 Oct 89 18:17:31 GMT Distribution: na Organization: Eaton Ion Beam Systems Division, Beverly, MA Lines: 36 I'd like to know if there is a standard way of building a varargs format argument list which is implementation independent (i.e. doesn't count on the existence of a (single) call frame pointer). Your program reads a socket which contains some arbitrary encoding of data items to be composed into a list, terminated somehow, and to be printed. You want to print the data using vprintf: #include #include int vprintf(format, ap) char *format; va_list ap; This is from the man pages for vprintf(3S). "format" is a print specification string. "ap" is the list of arguments used to satisfy the format specifications contained in "format". Assume that we already have a way of constructing the "format" string so that it completely represents the translation of each of the arguments in "ap" (for example, it may be part of an initialized array of format strings). How do you construct "ap"? Note you cannot assume that "ap" has a straight-forward implementation (such as a pointer to an "argument list" or a "stack".) This is especially true of RISC architectures where the components of a call frame may be spread out among a series of registers. You can use va_start, va_arg and va_end to access members of a varargs construct but there is no varargs constructor. Any reason for this? -- ____,.,_..,__.,_.,__ Sean Philip McElroy __'..__._,_.__.__.__ Eaton Corp., SED _,___`_.'__.__.__.__ 108 Cherry Hill Dr., Beverly, MA 01922 ___`..'_,___.__.__,_ uunet!etnibsd!sean