purported ANSI compiler in 5.1

Ken McDonell kenj at yarra.oz.au
Thu Mar 21 11:50:28 AEST 1991


Christopher-Vance at adfa.oz.au (Christopher JS Vance) writes:

>Having waited for some time for my sysadmin to install 5.1, I am
>dismayed to discover that the new-fangled cc, which we'd been led to
>believe was an ANSI compiler, is in reality only a compiler that can be
>persuaded to handle prototypes.  (Uhh, wow?!??)  No include files, no
>libraries.  It's even less ANSI than GNU gcc, which at least comes with
>a few include files. 

>From the OSx 5.1 Release Notes and C Programmer's Guide

[the compiler supports] ANSI C features (The ANSI C preprocessor, headers,
and library will be available in a later release).

The ANSI features include [a long list of stuff] -- somewhat beyond
"handling prototypes".

>Will somebody from Pyramid (or somebody else who knows) enlighten me:

>* if I declare a routine which has a variable number of arguments with
>the standard ANSI prototype (e.g., printf) and then call it, will my
>code link properly with the standard libraries?

Seems to -- see example below.

>* does anybody have a <stdarg.h> for this compiler that works? ...

Pyramid's one will be in the "later release", when the compiler will be ANSI
conformant, as opposed to offering ANSI features ...

>* if I declare a prototype with an ellipsis in the ANSI way, will I get
>compatible code at the *calling* side?

>* how do I write the *called* side of a function with the same prototype?

Here is a simple example -- when compiled with -Xa it executes correctly.

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	ansi.c
#	mumble.c
# This archive created: Thu Mar 21 11:48:14 EST 1991
export PATH; PATH=/bin:$PATH
echo 'x - ansi.c'
if test -f 'ansi.c'
then
	echo 'shar: over-writing existing file ansi.c'
fi
sed 's/^X//' > ansi.c <<'End-of-File-Grunt'
Xextern int printf(const char *fmt, ...);
Xextern int mumble(int a, ...);
X
Xmain()
X{
X    char	*p, *q, *r;
X
X    printf("hullo world\n");
X
X    p = "hullo world\n";
X    printf("%s", p);
X
X    p = "hullo";
X    q = "world";
X    r = "\n";
X    printf("%s %s%s", p, q, r);
X
X    printf("%d %d %d %d ... expect 0 1 2 30\n",
X	mumble(0), mumble(1,0), mumble(1,1,0),
X	mumble(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0));
X
X    exit(0);
X}
End-of-File-Grunt
if test 439 -ne `cat 'ansi.c' | wc -c`
then
	echo 'shar: transmission error (expected 439 characters)'
fi
echo 'x - mumble.c'
if test -f 'mumble.c'
then
	echo 'shar: over-writing existing file mumble.c'
fi
sed 's/^X//' > mumble.c <<'End-of-File-Grunt'
X#include <varargs.h>
X
Xint mumble(va_alist)
Xva_dcl
X{
X    va_list	ap;
X    int		k = 0;
X
X    va_start(ap);
X
X    while (1) {
X	if (va_arg(ap, int) == 0)
X	    break;
X	k++;
X    }
X
X    va_end(ap);
X
X    return k;
X}
X
End-of-File-Grunt
if test 206 -ne `cat 'mumble.c' | wc -c`
then
	echo 'shar: transmission error (expected 206 characters)'
fi

exit 0
-- 
Ken McDonell			  E-mail:     kenj at pyramid.com kenj at yarra.oz.au
Performance Analysis Group	  Phone:      +61 3 820 0711
Pyramid Technology Corporation	  Disclaimer: I speak for me alone, of course.
Melbourne, Australia



More information about the Comp.sys.pyramid mailing list