[11419] in Athena Bugs
decmips 7.6G: Green Hill C compiler and stdarg
daemon@ATHENA.MIT.EDU (Greg Hudson)
Tue Nov 23 18:04:31 1993
To: bugs@MIT.EDU
Date: Tue, 23 Nov 93 18:04:21 EST
From: Greg Hudson <ghudson@MIT.EDU>
System name: podge
Type and version: KN02ca 7.6G (1 update(s) to same version)
Display type: PMAG-DV
What were you trying to do?
Use the Green Hill C compiler from the multi locker
What's wrong:
Any function using variable arguments will fail. For instance,
in the following file (which I call test.c), the function f1()
comes from the example section of the ANSI X3.159-1989 C
standard, section 4.8.1.3:
#include <stdarg.h>
#define MAXARGS 31
void f1(int, ...);
void f2(int, char **);
void f1(int n_ptrs, ...)
{
va_list ap;
char *array[MAXARGS];
int ptr_no = 0;
if (n_ptrs > MAXARGS)
n_ptrs = MAXARGS;
va_start(ap, n_ptrs);
while (ptr_no < n_ptrs)
array[ptr_no++] = va_arg(ap, char *);
va_end(ap);
f2(n_ptrs, array);
}
void f2(int n_ptrs, char **ptrs)
{
}
main(int argc, char **argv)
{
return 0;
}
gcc (from the outland locker) compiles it just fine:
% which gcc
/mit/outland/decmipsbin/gcc
% gcc -v
Reading specs from /afs/sipb.mit.edu/project/gnu/lib/gcc-lib/mips-dec-ultrix4.2/2.5.4/specs
gcc version 2.5.4
% gcc test.c
%
But ghcc fails miserably:
% which ghcc
/mit/multi/decmipsbin/ghcc
% ghcc test.c
C-MIPS 1.8.7#09 Copyright (C) 1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993 Green Hills Software, Inc. All rights reserved.
"test.c", line 16: Undefined symbol: __va_ansiarg
"test.c", line 16: Operand must be an lvalue
"test.c", line 16: Type mismatch
"test.c", line 18: Illegal variable or expression
"test.c", line 18: Illegal variable or expression
"test.c", line 18: Illegal variable or expression
"test.c", line 18: Illegal variable or expression
"test.c", line 18: Indexing not allowed
"test.c", line 18: Type mismatch
"test.c", line 18: expected: ')' got: ';'
"test.c", line 18: expected: ')' got: ';'
"test.c", line 18: warning: Illegal combination of two pointers, when casting
char** to char*
%
This makes ghcc and multi completely worthless to me as
development tools. I suspect this is a simple configuration
problem, but it doesn't doesn't bode well at all that I'm
running into problems this fast.
What should have happened:
The file should have compiled successfully with no errors.
Please describe any relevant documentation references:
ANSI X3.159-1989