Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Can va_arg() be used as an lvalue? Message-ID: <378@taumet.com> Date: 4 Aug 90 19:22:23 GMT References: <1990Aug3.091749.10018@hellgate.utah.edu> Organization: Taumetric Corporation, San Diego Lines: 22 sandra%jensen.utah.edu@cs.utah.edu (Sandra Loosemore) writes: >The title says it all: is it legitimate, portable usage to treat >va_arg() as an lvalue? Specifically, can I take the address of its >return value? The ANSI C standard says (section 4.8.1.2): "The va_arg macro expands to an expression that has the type and value of the next argument in the call." An expression is not an lvalue. If you need to take the address of the parameter (as for passing the address to another routine), you can assigned it to a local temp and take the address of that. That is, instead of foo(&va_arg(ap, T)); you write T temp = va_arg(ap, T); foo(&temp); The latter has the same effect and is legal and portable. -- Steve Clamage, TauMetric Corp, steve@taumet.com