OT: Requesting C advice

Mike McCarty Mike.McCarty at sbcglobal.net
Thu May 31 22:01:15 UTC 2007


Andy Green wrote:
> Mike McCarty wrote:
> 
>>Andy Green wrote:
>>
>>>Mike McCarty wrote:
>>
>>[snip]
>>
>>
>>>>C doesn't initialize what? It initializes all used variables.
>>>
>>>
>>>Not if they're on the stack.  You should get a compiler warning
>>>nowadays... but don't count on it!
>>
>>Erm, C knows nothing about a "stack". However, it is true
>>that automatic variable are not necessarily initialized.
>>I should have stated that all statically allocated variables
>>are initialized. Thanks for the correction.
> 
> 
> You're welcome.
> 
> I think you have to draw a line between the glorious worlds of
> possibility left open by the wording of the standard and the grimy
> reality of the actual compilers.  "Automatic variables" will be
> allocated off the stack frame on any actual compiler that is worth the name.

I wonder what you mean by "any actual compiler that is worth
the name". The 8051 normally uses no stack at all.

> Though back in the day I did read about a C "compiler" for a tragic arch
> that neither had a stack nor more than 256 bytes of RAM IIRC... it
> disallowed recursion or more than 2 function call depth...  other than
> that I propose any compiler will be using a stack frame whether the word
> is in the standard or not ;-)

The 8051 has Harvard architecture, giving it 64K of data space and 64K
of program space. But it has no real stack, so compilers for it normally
don't implement one unless specifically requested so to do. Doing so
causes a significant execution penalty. There are LOTS of 8051s (and
its progeny) out there.

Mike
-- 
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Oppose globalization and One World Governments like the UN.
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!




More information about the fedora-list mailing list