From owner-freebsd-ia64@FreeBSD.ORG Wed Apr 21 09:53:08 2004 Return-Path: Delivered-To: freebsd-ia64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4E95516A4CE for ; Wed, 21 Apr 2004 09:53:08 -0700 (PDT) Received: from ns1.xcllnt.net (209-128-86-226.BAYAREA.NET [209.128.86.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id E682143D58 for ; Wed, 21 Apr 2004 09:53:07 -0700 (PDT) (envelope-from marcel@xcllnt.net) Received: from ns1.xcllnt.net (localhost [127.0.0.1]) by ns1.xcllnt.net (8.12.11/8.12.11) with ESMTP id i3LGr7QN001045; Wed, 21 Apr 2004 09:53:07 -0700 (PDT) (envelope-from marcel@ns1.xcllnt.net) Received: (from marcel@localhost) by ns1.xcllnt.net (8.12.11/8.12.11/Submit) id i3LGr7HT001044; Wed, 21 Apr 2004 09:53:07 -0700 (PDT) (envelope-from marcel) Date: Wed, 21 Apr 2004 09:53:07 -0700 From: Marcel Moolenaar To: Valentin Nechayev Message-ID: <20040421165307.GB832@ns1.xcllnt.net> References: <20040421155127.GS57650@netch.kiev.ua> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="n8g4imXOkfNTN/H1" Content-Disposition: inline In-Reply-To: <20040421155127.GS57650@netch.kiev.ua> User-Agent: Mutt/1.5.5.1i cc: ia64@freebsd.org Subject: Re: va_list q X-BeenThere: freebsd-ia64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the IA-64 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Apr 2004 16:53:08 -0000 --n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Apr 21, 2004 at 06:51:27PM +0300, Valentin Nechayev wrote: > > cc -O -pipe -g -I../include -DHAVE_PATHS_H -D_BITYPES -c utils.c > utils.c: In function `vslprintf': > utils.c:253: error: invalid use of non-lvalue array > *** Error code 1 > > The code in question is: > > int > vslprintf(buf, buflen, fmt, args) > [...] > #ifndef __powerpc__ > > n = vslprintf(buf, buflen + 1, f, va_arg(args, va_list)); > #else > /* On the powerpc, a va_list is an array of 1 structure */ > n = vslprintf(buf, buflen + 1, f, va_arg(args, void *)); > #endif > > (I selected failed line with '>') > > va_arg() uses translation to pointer to specified type; this translation > fails with message shown above. Can anybody say how can it be fixed, > and whether shown powerpc hack is applicable to ia64 if it's good solution? The use of va_arg(args, va_list) works on ia64 (FreeBSD, HP-UX and Linux). Given the limited context, I can only suggest that you try to create a temporary variable of type va_list and change the offending line to: va_list tmpvalist = va_arg(args, va_list); n = vslprintf(buf, buflen + 1, f, tmpvalist); This may make the compiler happy by giving it more type awareness. Attached a simple testcase that va_arg(ap, va_list) works. -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net --n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="arg.c" #include #include int vf2(int count, va_list ap) { va_list val; int i, n; printf("%d ->", count); val = va_arg(ap, va_list); for (i = 0; i < count; i++) { n = va_arg(val, int); printf(" %d", n); } printf("\n"); return (0); } int f2(int count, ...) { va_list ap; int ret; va_start(ap, count); ret = vf2(count, ap); va_end(ap); return (ret); } int vf1(int count, va_list ap) { return (f2(count, ap)); } int f1(int count, ...) { va_list ap; int ret; va_start(ap, count); ret = vf1(count, ap); va_end(ap); return (ret); } int main() { return (f1(3, 1, 2, 3)); } --n8g4imXOkfNTN/H1--