Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Apr 1995 08:24:18 +0200 (MET DST)
From:      J Wunsch <j@uriah.heep.sax.de>
To:        freebsd-hackers@FreeBSD.org (FreeBSD hackers)
Subject:   Re: 90's compilers
Message-ID:  <199504150624.IAA01712@uriah.heep.sax.de>
In-Reply-To: <199504142309.TAA03606@hda.com> from "Peter Dufault" at Apr 14, 95 07:09:26 pm

next in thread | previous in thread | raw e-mail | index | archive | help
As Peter Dufault wrote:
> 
> If you're proposing changing the coding guidelines away from KNF
> on this I'm all for it.

There has never been an `official' coding guideline to keep KNF.  In
fact, some device drivers under i386/isa do already fully use `new'
style.

The boot code has been crying for a revamp.  The writers didn't even
bother to declare external functions at all (``all the world is an
int, and might take any possible number of arguments'' :).  There have
been many errors in the code (functions that actually take a `char'
argument, while the compiler promoted it to `int' -- works only since
we're little-endian).

This style made it highly error-prone.

ANSI-style function declaration seems to be much more rationale, and
if done consistently from hour 0 of some new portion of code, it ain't
more work.  But it's not only function declarations, consider the
following piece of code:

-       /* This is ugly, but why use 4 printf()s when 1 will do? */
-       printf("\n\
->> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n\
-Use hd(1,a)/kernel to boot sd0 when wd0 is also installed.\n\
-Usage: [[%s(%d,a)]%s][-abcdhrsv]\n\
-Use ? for file list or press Enter for defaults\n\n",
+       printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n"
+              "Use hd(1,a)/kernel to boot sd0 when wd0 is also installed.\n"
+              "Usage: [[%s(%d,a)]%s][-abcdhrsv]\n"
+              "Use ? for file list or press Enter for defaults\n\n",

Why use the ugly style (and document it to be ugly) if we can do it
better?

> I can't imagine what we would ever port to that wouldn't have a
> decent compiler - I wouldn't choose a microcontroller compiler that
> didn't support Standard C.

Our only non-ANSI-conforming compiler by now is bcc.  It's scope is
limited to few areas, however.

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199504150624.IAA01712>