🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #52164

Trouble gcc 2.2.2 & varargs on HPPA

#52164
From: Steven Buytaert
Date: Mon, 01 Feb 1993 09:05
188 lines
6168 bytes
  Hello,

  I noticed that this is a very busy newsgroup. I hope some of you can help
  me out with the following problem...

  I have a problem using varargs with gcc 2.2.2 on a HP PA machine.

  I did the following to build gcc 2.2.2

  1) Changed the Makefile.in to reflect my preferences
  2) I ran configure hp730. The result of the uname -a command was
     the following : HP-UX kwak A.08.07 A 9000/730 2004632177
  3) I built the boot compiler
  4) I built a stage2 and a stage3 compiler and compared both.
     They were identical...
  5) I ran the install procedure to install gcc 2.2.2
  6) I ran fixinc.svr4 on my machine...

  In fact, all compiles and runs fine with gcc 2.2.2 except when using
  varargs. I isolated the following code to illustrate what goes wrong.
  When compiling, gcc answers me :
  test.c: In function `test':
  test.c:14: incompatible type for argument 2 of `vprintf'
  Together with the code I include the preprocessed output. Excuse me for this
  lengthy mail, but I really think it is necessary to include this information.
  
  Thanks for your time...I would prefer e-mail replies, except when you think
  that others could use this information as well...
  
Steven Buytaert
IMEC - Invomec Division
Kapeldreef 75, 3001 Heverlee

phone  : + 32 16 281 271
fax    : + 32 16 281 584
e-mail : buytaert@imec.be

                     In case of danger, BREAK glass

// test.c included ...

#include <stdio.h>
#include <varargs.h>

void test(va_alist)
va_dcl /* NO semicolon ! */

{

  va_list argumentList;
  char *format;

  va_start(argumentList);
  format = va_arg(argumentList, char *);
  (void)vprintf(format, argumentList); 
  va_end(argumentList);

}

void main() {

  test("OK, this is a test %s %s %d %d %d\n", "haha", "hihi", 1, 2, 3);

}

// preprocessed code ...

# 1 "test.c"

# 1 "/usr/include/stdio.h" 1 3

# 1 "/usr/include/sys/stdsyms.h" 1 3

# 59 "/usr/include/sys/stdsyms.h" 3

# 84 "/usr/include/sys/stdsyms.h" 3

# 123 "/usr/include/sys/stdsyms.h" 3

# 6 "/usr/include/stdio.h" 2 3

   typedef struct {
	int		 __cnt;
	unsigned char	*__ptr;
	unsigned char	*__base;
	unsigned short	 __flag;
	unsigned char 	 __fileL;		 
	unsigned char 	 __fileH;		 
   } FILE;

   typedef struct {
	int		 __cnt;
	unsigned char	*__ptr;
	unsigned char	*__base;
	unsigned short	 __flag;
	unsigned char 	 __fileL;		 
	unsigned char 	 __fileH;		 
	unsigned char	*__bufendp;	 
	unsigned char	 __smbuf[8 ];  
   } _FILEX;

     typedef unsigned int size_t;
     
[...]

     typedef double *__va_list;

   extern FILE __iob[];

[...]

     extern int vprintf(const char *, __va_list); /* <<<!!!!!!!! */
     
[...]

# 184 "/usr/include/stdio.h" 3

# 1 "test.c" 2

# 1 "/usr/users/invomec/buytaert/local/lib/gcc-lib/hp730/2.2.2/include/varargs.h" 1 3

# 1 "/usr/users/invomec/buytaert/local/lib/gcc-lib/hp730/2.2.2/include/va-hp800.h" 1

typedef struct
{
  char *__va_stack_start;	 
  char *__va_int;		 
				 
  char *__va_float;		 
  char *__va_double;
} va_list;

# 45 "/usr/users/invomec/buytaert/local/lib/gcc-lib/hp730/2.2.2/include/va-hp800.h"

void va_end (va_list);		 

# 86 "/usr/users/invomec/buytaert/local/lib/gcc-lib/hp730/2.2.2/include/va-hp800.h"

# 29 "/usr/users/invomec/buytaert/local/lib/gcc-lib/hp730/2.2.2/include/varargs.h" 2 3

# 102 "/usr/users/invomec/buytaert/local/lib/gcc-lib/hp730/2.2.2/include/varargs.h" 3

# 2 "test.c" 2

void test( __builtin_va_alist )
   int __builtin_va_alist; ...   

{

  va_list argumentList;
  char *format;

  ((argumentList) = *(va_list *)__builtin_saveregs()) ;
  format = ((((((sizeof ( char *) + sizeof (int) - 1) /       \
  sizeof (int)) * sizeof (int))  <= 8)	? ((argumentList).__va_int -=    \
  (((sizeof ( char *) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) ,   \
  (argumentList).__va_float -= (((sizeof ( char *) + sizeof (int) - 1) /  \
  sizeof (int)) * sizeof (int)) , \
  (argumentList).__va_double -= (((sizeof ( char *) + \
  sizeof (int) - 1) / sizeof (int)) * sizeof (int)) , \
  (__alignof__ ( char *) > 4 ? ((int)(argumentList).__va_int &= \
  ~(0x7), (int)(argumentList).__va_float &= ~(0x7), \
  (int)(argumentList).__va_double &= ~(0x7)) : 0)) : \
  (int)((argumentList).__va_int -= sizeof ( char * *), \
  (argumentList).__va_float -= sizeof ( char * *), \
  (argumentList).__va_double -= sizeof ( char * *))), \
  (((argumentList).__va_int < (argumentList).__va_stack_start \
  || __builtin_classify_type (* ( char * *) 0) != 8) \
  ? (((((sizeof ( char *) + sizeof (int) - 1) / sizeof (int)) * \
  sizeof (int))  <= 8) ? *( char * *)(argumentList).__va_int \
  : **( char * **)(argumentList).__va_int) \
  : (((((sizeof ( char *) + sizeof (int) - 1) / \
  sizeof (int)) * sizeof (int))  <= 4) ? \
  *( char * *)(argumentList).__va_float	: \
  (((((sizeof ( char *) + sizeof (int) - 1) / \
  sizeof (int)) * sizeof (int))  <= 8) ? \
  *( char * *)(argumentList).__va_double \
  : **( char * **)(argumentList).__va_int)))) ;
  (void)vprintf(format, argumentList); 
   ;

}

void main() {

  test("OK, this is a test %s %s %d %d %d\n", "haha", "hihi", 1, 2, 3);

}
Technical Details
Message-ID: <1993Feb1.090506.13157@imec.be>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!ub4b!imec.be!imec!buytaert

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,c97285fca94813db,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-02-01 01:05:06 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!ub4b!imec.be!imec!buytaert
From: buytaert@imec.be (Steven Buytaert)
Subject: Trouble gcc 2.2.2 & varargs on HPPA
Message-ID: <1993Feb1.090506.13157@imec.be>
Summary: problems when using varargs on a HPPA with vprintf()
Keywords: varargs, vprintf, HPPA
Sender: news@imec.be (USENET News System)
Nntp-Posting-Host: imec
Organization: IMEC V.Z.W,Interuniversitair Micro Electronica Centrum, Belgium
X-Newsreader: Tin 1.1 PL4
Date: Mon, 1 Feb 1993 09:05:06 GMT
Lines: 188