🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42719

Variable Number of Arguments Problem

#42719
From: Ronald Pierce
Date: Thu, 02 Nov 1995 00:00
42 lines
1593 bytes
/* 
   Please Help!
     
   I'm using the GNU "C" compiler (2.5.8/2.6.0) on the Sun OS 4.1.3  
   platform and am having problems with the "Variadic" functions 
   (variable length parameter lists). I've been able to make this 
   code run fine on a PC Ansi compiler (Borland "C") with no changes. 
   This SHOULD be ANSI/ISO C compatible code. I am using the precompiled 
   version off of the Walnut Creek CD-Rom.
    
   To Compile: gcc -I/GNU/include -Dsparc main.c
    
   I get the error:
     
     main.c: In function `addnbrs':
     main.c:36: too many arguments to function `__builtin_next_arg'
     
   Thanks in Advance for any help.
*/
   
#include <stdio.h>
#include <stdarg.h>
int addnbrs(int i, ...);
int main(int argc, char * argv[]);
      
int main(int argc, char * argv[])
{
printf("addnbrs: %d\n", addnbrs(1, 4));
}
   
int addnbrs(int i, ...)
{
   va_list ap;
   int     newval;

   va_start(ap, i);   /* This statement is generating the error */

   printf("%d parameters\n", i);
   newval = va_arg(ap, int);
   va_end(ap);   
   return(newval + 2);
}
Technical Details
Message-ID: <3099B4F9.3492@execpc.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,195e33b72825e8df,start
X-Google-Attributes: gid11318c,public
From: Ronald Pierce <rpierce@execpc.com>
Subject: Variable Number of Arguments Problem
Date: 1995/11/02
Message-ID: <3099B4F9.3492@execpc.com>
X-Deja-AN: 118621452
content-type: text/plain; charset=us-ascii
organization: Exec-PC BBS - Milwaukee, WI
mime-version: 1.0
newsgroups: gnu.gcc.help
x-mailer: Mozilla 2.0b1 (Windows; I; 16bit)