Re: C90 penetration
- From: James Kuyper <jameskuyper@xxxxxxxxxxx>
- Date: Thu, 26 Mar 2009 14:26:02 GMT
kerravon wrote:
On Mar 26, 10:52 pm, Tristan Miller <psychon...@xxxxxxxxxxxxxxxxx>
wrote:
I doubt that there's a GCC cross-compiler for the 6502, though there is a
Free cross-compiler specifically written for that processor; namely, cc65.
Thanks for the pointer!
http://www.cc65.org/
It describes itself as "almost ISO C compatible", though that might be a
bit generous: among the ISO/ANSI C features it does not support include
the float and double datatypes,
Would it be legal for a C90 compiler to define both of
these as a long, and just specify that the "precision"
is such that it "rounds" at 1?
That's inconsistent with (among many other things) the maximum values for FLT_EPSILON and DBL_EPSILON specified in 5.2.4.2.2p11.
....
The other thing is bitfields. I wonder if those can
be legally represented at chars.
Any platform which allows implementation of the bitwise operators will also allow implementation of bit-fields.
A bit-field whose size is CHAR_BIT, can certainly be represented by a char; bit fields of a larger size clearly cannot be represented as a single char. Bit fields of a smaller size must behave as if they only had the specified number of bits: for instance, storing a -1 in an unsigned bit-field with a width of 3 has to produce a result of 7, not UCHAR_MAX. This would require bit-wise manipulation just as complicated as that required to implement bit-field that only take up the specified number of bits, so there doesn't seem much point to it.
Also, the standard requires that if a bit field with a width of (for instance) 3 is followed by a bit field with a width of 4, then if there's enough room in the allocation unit (which is guaranteed to be the case for those two numbers), they must be allocated in adjacent bits within that allocation unit; that's pretty hard to do if you implement them as chars.
Though it's primarily intended for cross-compiling to
1980s microcomputers and game consoles, the author claims that the runtime
library and standard C library are sufficiently portable that they should
work with any 6502 system (presumably including modern-day embedded
systems).
Except for the file I/O of course. Which is the biggest thing.
A conforming implementation of C can have file I/O that always fails: nothing is the standard requires that any I/O function call must succeed. Of course, the simplest approach is to conform only to the requirements for a freestanding implementation, in which case the <stdio.h> portion of the standard library need not be implemented at all.
.
- Follow-Ups:
- Re: C90 penetration
- From: kerravon
- Re: C90 penetration
- References:
- C90 penetration
- From: kerravon
- Re: C90 penetration
- From: Eric Sosman
- Re: C90 penetration
- From: Stephen Sprunk
- Re: C90 penetration
- From: Jack Klein
- Re: C90 penetration
- From: Tristan Miller
- Re: C90 penetration
- From: kerravon
- C90 penetration
- Prev by Date: Re: cooking the spaghetti
- Next by Date: Re: C90 penetration
- Previous by thread: Re: C90 penetration
- Next by thread: Re: C90 penetration
- Index(es):
Relevant Pages
|