[haiku-development] Re: Of errno signedness and standards

  • From: "François Revol" <revol@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 20 Jan 2009 06:45:48 +0100 CET

> > However it seems too that ANSI C (C89 and now C99) also defines
> > errno
> > and 2 of the errors (EDOM and ERANGE), as >0.
>
> Interesting. That invalidates our argument that BeOS using negative
> error
>  codes
> predates any standard. So, in fact, the Be developers got us into
> this
> mess, not
> the people who added the requirement to the standard.

Well, C89 wasn't so widespread at the time, and expensive as well...
Don't expect people to comply to something they can't afford.

> > What I have read from the available drafts seemed confuse enough to
> > give me a headache. And we aren't changing our errors any time soon
> > anyway.
>
> I'd actually vote for making the POSIX error codes standard compliant
> as soon as
> we have a chance. That is when we break binary compatibility. I would
> keep the Be
> API error codes negative, but change them to small absolute values,
> so that
> B_FOO_BAR == -EFOOBAR. This allows us to continue using the Be API as
> we're used
> to. Care must be taken when mixing Be and POSIX API though. I'd
> introduce two
> macros, B_TO_POSIX_ERROR() and B_TO_HAIKU_ERROR(), to convert the
> error codes
> where necessary. Our complete code base would have to be adjusted,
> which should
> be quite a bit of work, but compared to the overhead of forever
> "fixing" ported
> code -- and we all know this code will keep coming -- it will be more
> than
> worthwhile. We could even introduce and use the macros already; they
> would just
> be identity functions for the time being.

This seems quite ugly though...
I suppose we have some time ahead to think about it, or buy ANSI
people.


François.

Other related posts: