GCC and IRIX 3.3.1

Knobi der Rechnerschrat XBR2D96D at DDATHD21.BITNET
Thu Nov 1 03:43:29 AEST 1990


Hallo,

  an addition to my previous posting about installing gcc-1.37.1 on
IRIX 3.3.1:

 you have also to modify the distributed version of stdarg.h. It's the
same  problem as with va-mips.h. The differences are as follows:

------------------------ diffs for stdarg.h ----------------------
*** stdarg.oh   Wed Oct 31 17:23:48 1990
--- stdarg.h    Wed Oct 31 17:24:15 1990
***************
*** 2,5 ****
--- 2,10 ----
  #define _STDARG_H

+ /* This is for IRIX 3.3.1 , M. Knoblauch */
+ #ifdef sgi
+ #define _VA_LIST_
+ #endif
+
  typedef char *va_list;

---------------------------------------------------------------------
  Unfortunatelly I had to discover, that the stdarg mechanism does not
work. The following C program compiled with gcc-1.37.1 gives the shown
results:

----------------------------- t2.c ----------------------------------
#include <stdarg.h>
#include <stdio.h>

main()
{
blaa("Test  0\n");
blaa("Test  1 %s\n","string");
blaa("Test  2 %d\n",4711);
blaa("Test  3 %f\n",4712.);
blaa("Test  4 %s %f\n","string",4712.);
blaa("Test  5 %s %f %d\n","string",4712.,4711);
blaa("Test  6 %s %d %f\n","string",4712,4711.);
blaa("Test  7 %s %d %d \n","string",4712,4711);
blaa("Test  8 %s %d %d %d\n","string",4712,4711,4713);
blaa("Test  9 %d %d %d %d\n",4712,4711,4713,4714);
}

#define LINELEN 100

blaa(char *fmt, ...)
{
va_list  ap;
char     *fp;
register int c;

char buffer[100];
char note[LINELEN],format[10];
int b,j,i,fi,narg;


narg = i = b = fi = 0;

  va_start(ap,fmt);
  fp =  fmt;

  while( ( c = *fp++) != '\0' )
    if( c != '%' ) buffer[b++] = c;
    else
      {
      format[fi++] = c;
      while( ((c = *fp++) != 'd') && (c != 'f') && (c != 's') ) format[fi++]=c;
      format[fi++] = c;  format[fi] = 0;
      switch( c )
         {
         case   'd' : sprintf(note,format,va_arg(ap,int));narg++;
                      break;
         case   'f' : sprintf(note,format,va_arg(ap,double));narg++;
                      break;
         case   's' : sprintf(note,format,va_arg(ap,char *));narg++;
                      break;
         default    : note[0] = c; note[1] = '\0';
                      break;

         }
      j = 0;  fi = 0;
      while( ( buffer[b++] = note[j++]) != '\0');  b--;
      }
   buffer[b] = '\0';
   va_end(ap);

   printf("narg = %d:%s",narg,buffer);
}  /* end eprint */
--------------------------------end-----------------------------------

narg = 0:Test  0
narg = 1:Test  1 (null)
narg = 1:Test  2 0
narg = 1:Test  3 0.000000
narg = 2:Test  4 (null) 0.000000
narg = 3:Test  5 (null) 0.000000 4711
narg = 3:Test  6 (null) 0 0.000000
narg = 3:Test  7 (null) 0 0
narg = 4:Test  8 (null) 0 0 4713
narg = 4:Test  9 0 0 0 4714

 This output is definitelly not as expected. From Test_5, Test_8
and Test_9 one can see that the first 12 Byte on the argument-List
are corrupted. After that arguments are  processed correct. Has anybody
seen this problem before? The program works fine when compiled with
cc.

 Btw. does an gcc version exist for the 4D series, that supports
debugger (either dbx or gdb) operations?

Regards
Martin Knoblauch

TH-Darmstadt
Physical Chemistry 1
Petersenstrasse 20
D-6100 Darmstadt, FRG

BITNET: <XBR2D96D at DDATHD21>



More information about the Comp.sys.sgi mailing list