[fpc-pascal] Syserrormessage, parameter data type

Jürgen Hestermann juergen.hestermann at gmx.de
Sun Oct 5 12:27:18 CEST 2014


Am 2014-10-05 um 12:10 schrieb Michael Van Canneyt:
> Not necessarily, because it is a cross-platform function and on other systems the error codes are not necessarily positive values.
> Unfortunately, this kind of windows-api-creep is found throughout the RTL.
>
> The proper procedure is probably to introduce TSysErrorCode which depends on the platform, and replace integer/dword with that.
> Please file a bug-report, so we do not forget this.

But the current situation is wrong for *all* plattforms because the sequence DWORD-INTEGER-DWORD
does not work and when it becomes INTEGER-INTEGER-DWORD it doesn't work either.
The FormatMessageA call within SysErrorMessage expects DWORD too but an INTEGER is provided.

If GetLastError sometimes gives back a DWORD (Windows) and sometimes an INTEGER (Linux) then
the complete sequence GetLastError-SysErrorMessage-FormatMessageA needs to become platform
dependend to solve this. But as long as this is not the case at least one platform (Windows) would
work okay when the parameter in SysErrorMessage becomes DWORD too. In the current situation
it *never* works correctly (not even for Linux).




More information about the fpc-pascal mailing list