[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] How TCC handlse the scope

From: Rob Landley
Subject: Re: [Tinycc-devel] How TCC handlse the scope
Date: Sat, 23 Jun 2007 00:48:01 -0400
User-agent: KMail/1.9.6

On Friday 22 June 2007 18:29:34 David A. Wheeler wrote:
> If you call a function that hasn't
> been defined, C assumes that it takes an int, and returns an int, no matter
> what it REALLY does.

Actually, C assumes it takes all varargs and returns an int.  int blah(...);
(see "man 3 va_arg".)

Way back when (before the Ansi C 89 standard) there were no function 
prototypes, so every function was expected to do the above.  This works for a 
surprising number of things because on a 32-bit platform, any pointer can be 
cast to an int and back so things that return pointers work if you return 
ints.  Basically there was a register in which to expect the return value.

On a 64-bit platforms this doesn't work, because it would have to default to 
long to hold a pointer and everybody just says "prototype the darn thing 
already".  But then 64 bit platforms are a relatively recent invention (the 
DEC Alpha was around 1993 I think).  The standards for them are even more 

"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]