"Incompatible types: 'PWideChar' and 'Pointer'" in call of FormatMessage()
Opened this issue · 0 comments
jottkaerr commented
The call to FormatMessage()
can only be compiled with {$TYPEDADDRESS OFF}
. Otherwise
Lines 430 to 438 in f5d05ba
will result in a compiler error:
[dcc32 Error] SCrypt.pas(438): E2010 Incompatible types: 'PWideChar' and 'Pointer'
(translated from German). This is due to @Buffer
being a pointer to PChar
while FormatMessage()
formally expects a PChar
, though because of the combination of flags provided in the first parameter the provided pointer is actually treated as a pointer to PChar
internally.
There are two solutions to this problem:
- Put a
{$TYPEDADDRESS OFF}
at the top of the unit, or - put a typecast around
@Buffer
, i.e.,PChar(@Buffer)
I think the second solution is preferrable, because it makes the special handling of this argument more explicit.