www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/07/02/05:13:41

Sender: bill AT delorie DOT com
Message-ID: <377C5992.5C5154C2@taniwha.org>
Date: Fri, 02 Jul 1999 18:17:54 +1200
From: Bill Currie <bill AT taniwha DOT org>
X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.2.9 i486)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: Regparm and asm statements.. what now?
References: <Pine DOT SUN DOT 3 DOT 91 DOT 990701123158 DOT 10503G-100000 AT is>
Reply-To: djgpp-workers AT delorie DOT com

Eli Zaretskii wrote:
> 
> On Wed, 30 Jun 1999, Bill Currie wrote:
> 
> > > > According to ANSI C, users can legitimately do that, and still assume
> > > > they get a working program.
> >
> > IMHO, broken spec.  Nuff said.
> 
> This ``broken spec'' has survived for 10 years with virtually no
> changes, C being the most used language all that time.
> 
> IMHO, every ruling of the ANSI C standard has very good reason for
> being there.

Sorry, you're right about this, of couse.  I was thinking no prototypes
at all.  I've had problems with this when sizeof(char*)!=sizeof(int).

> In this case, there are tons of programs out there which
> say things like "char *malloc();" instead of including the header,
> because some old compilers didn't have prototypes for some functions,
> notably those which return an int.

Yes, there are a lot of programs that do that (and need to,
unfortunatly), but as the  Ten Commandments of C Programming
(http://www.ee.ryerson.ca:8080/~elf/hack/The10.html) states
(paraphrased): if you do this, KMACYOYO.  It's not a safe thing to do
(eg char * vs char far * in 16bit dos compilers) when the calling
convetion can change under your feet.  I've been burned by this, so I'm
not just spouting dogma.  However, I agree, you *should* be able to do
this safely (gcc's multilibbing should help, but it's expensive).

Bill
-- 
Leave others their otherness.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019