At 01:06 AM 3/31/2002 -0500, Michael G Schwern wrote:
>On Sun, Mar 31, 2002 at 12:49:08AM -0500, Melvin Smith wrote:
> > I did some browsing of the code for potential problems in compiling
> > for embedded platforms and/or general porting and here are some of the
> > things I found.
>
>Do embedded C compilers often not conform to ANSI C 89?

Yes and no, depending on your definition.

ANSI C 89 specificies "free-standing environments" and "hosted"
environments. It does not require the former to provide any
more than these 4 -> (float.h, limits.h, stdarg.h, stddef.h), besides
the language proper itself.

To qualify as a "hosted" environment they must provide the larger
list (stdio, stdlib, signal, string, assert, ctype, errno, locale, limits,
math, setjmp, stdarg, stddef, time).

WinCE on PocketPC is in my book a "free-standing" environment
by this definition. I've also coded on the Intel 8051 MC once upon a time
and I think I had some of the same issues, but its too fuzzy to
remember now.

CE is coming along though, 2.0 didn't provide stdio stuff, but 3.0 does
have some limited stuff.

> > 1- assert.h and use of assert()
> >     assert is easy enough to implement we need to do this and not depend
> >     on its existence on the target because its not guaranteed.
>
>assert is part of ANSI C 89, it should always be there.  The only
>limitation is the expression must be an int.
>
>
> > 2- errno.h same thing.
>
>errno is also in ANSI C 89.

I'm not saying we shouldn't use it or include it, just not in the general
naked includes.

>However, using errno to transmit error messages has bitten us in the
>ass in Perl5.

Well for one, assert is so easy to implement its really kind of dumb that
the host compiler doesn't have it, but its also not worth fretting about, 
either.

However, anywhere we use assert() is probably a candidate for using
the Parrot exception routine anway.

-Melvin

Reply via email to