[fpc-pascal] Syserrormessage, parameter data type
Michael Van Canneyt
michael at freepascal.org
Sun Oct 5 15:08:23 CEST 2014
On Sun, 5 Oct 2014, Jürgen Hestermann wrote:
>
> 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.
A typecast will be needed somewhere.
>
> 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).
That is why we need an opaque type which will probably be used in more than one call.
It needs to be investigated, hence the bugreport is needed.
Michael.
More information about the fpc-pascal
mailing list