[haiku-development] Re: POSIX error code

  • From: kaoutsis <kaoutsis@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 21 May 2008 02:05:51 +0300

Ingo Weinhold wrote:
wrote:
Anyway, it certainly doesn't harm to try, but I have little hope that this will have any effect. If the standard maintainers consider the request, they are in a dilemma. Undoing the Issue 6 error codes change means that all the applications that relied on it would become non-conforming.

I agree.
I had an idea how to tackle the problem, may be good, may be bad:


in the Errors.h:
#ifndef _ERRORS_H
#define _ERRORS_H

#if  GCC_VERSION < 4
#include <Errors_legacy.h>
   // the Errors_legace.h would have
   // unmodified the current error values
   // (in short: keep the current stutus for the legacy compiler)
#else
   // new era,
    // if (status < B_OK)
    // something bad happened (still valid)
   // also posix error codes are now positives
#include <Errors_posix_conformance.h
   // that file should contain something like this:
   // #define B_OK                                        LONG_MAX
   // #define B_NO_ERROR                           LONG_MAX
   // #define B_ERROR                                  LONG_MAX - 1
   // #define B_GENERAL_ERROR_BASE      LONG_MAX - 2
// #define B_OS_ERROR_BASE (B_GENERAL_ERROR_BASE - 0x1000) // #define B_APP_ERROR_BASE (B_GENERAL_ERROR_BASE - 0x2000)
   // ...

   // #define B_NO_MEMORY                      (B_GENERAL_ERROR_BASE - 0)
// #define B_IO_ERROR (B_GENERAL_ERROR_BASE - 1)
   ...

#endif
#endif    /* _ERRORS_H */

good bye,
   Vasilis


Other related posts: