[fpc-pascal] Negative RTL Error Codes in Some Platforms

Tomas Hajny XHajT03 at hajny.biz
Thu Jun 10 08:46:39 CEST 2010


On Thu, June 10, 2010 05:44, Bihar Anwar wrote:
> I look at the FPC RTL source codes and notice that in some OSes (e.g.
> OS/2, DOS) every RTL functions which call OS API functions will return the
> OS error code as a negative number. What is the reason behind this? I
> don't find such a convention in the official documentation of thouse OSes.

If I remember correctly, it's been done in order to differentiate standard
error codes (supposedly cross-platform and mostly inherited from TP/BP)
from all other error codes which may be triggered there and which are
completely platform specific. It's well possible that this convention has
never been documented and possibly not followed in implementations for
other platforms either. However, you shouldn't rely on the returned values
too much anyway. They depend not only on the underlying platform, but
possibly partly also on the specific implementation for the particular
platform - i.e. one RTL function originally based on a single OS API call
in the DOS (TP) times may require several subsequent OS API calls in an
implementation for another platform and you wouldn't really know which of
the calls returned the value and why unless you trace the implementation.

Tomas





More information about the fpc-pascal mailing list