[comp.os.minix] Up and coming c compiler...

cagney@chook.ua.oz (really from Bob Lunnon) (02/09/90)

In response to a question about MINIX and ansi I recently posted I received
the below reply.  The comment at the *end* is most interesting...

From r_prandolini@csvax.qut.oz Thu Feb  1 19:08:41 1990
Date: Thu, 1 Feb 90 19:04:34 EST
Subject: sort of error in 1.5.0 stdio.h

> From: cagney@chook.ua.oz (Andrew Cagney - aka Noid)
> Subject:sort of error in 1.5.0 stdio.h
> Date: 28 Jan 90 11:55:45 GMT

> While compiling scanf.c with an ansi compiler I encountered the error below.
> If you are using the ACK compiler this error isn't very interesting.
> 
> In stdio.h there is the definition
> 	#define	__STDIO_VA_LIST__	void *
> and a declaration
> 	_doscanf( ..... , __STDIO_VA_LIST__)
> (...... are other arguments).
> 
> but in the file scanf.c _doscanf is declared as:
> 	_doscanf( ..... , va_list arg)
> where va_list is defined in stdarg.h as
> 	typedef char *va_list
> Consequently when compiling with an ansi compiler, a parameter type missmatch
> error is generated because:
> 	void*	!= char*
> 
> If you are using an ANSI compiler the simple fix is to modify stdio.h so that
> 	1. It includes <stdarg.h>
> 	2. defines
> 		#define __STDIO_VA_LIST__ va_list
> 
> or alternativly, just wait until the `official replacement' for stdio comes out
> :-)
> 
> 				Andrew Cagney

There are hundreds of these types of problems in the Minix distribution, I am
no C or U**X genius but....

1.) a type should not be typed in more than one place anyway usually this is
controlled with #ifdefs.

2.) Have a look through your header files for eg: stat.h signal.h and sgtty.h
    now find all the references to type int. Arrrggghhhh !

This doesn't mean much to you but recently Clyde Smith-stubbs of Hitech 
software and I worked through a port of HITECH C to Minix ST ( Minix PC
version to be released soon ) This is an ansi C compiler but the ST version i
a general 680x0  compiler and uses 32 bit integers !!!

since the 68K stores longs as HMML if you pass a pointer to a struct with
a short in it and reference it as an int the short goes in the most sig.
word of the result. This makes many programs fall over in a big heap ....

(Stty.c) for example failed to set the Baud rate properly.


The moral of the story really is 
1.) Use prototypes so coercion of int parameters is possible.
2.) NEVER Use int;

I would have posted this but I can't do that successfully at the moment :-(

If you wish to pass on this observation to the net please. Be my guest.

BTW I am taking advance orders for HITECH C ST & PC Minix versions :-)

             BOB
                  EEZPRANDOLIN@qut.edu.au
Bob Lunnon sharing this acct.