RAD Studio (Common)
ContentsIndex
PreviousUpNext
W1044: Suspicious typecast of %s to %s (Delphi)

This warning flags typecasts like PAnsiChar(String) or PChar(AnsiString) which are casting between different string types without character conversion. If the code generating this warning calls a Win32 API routine, be sure that you use the wide version of the Win32 API routine when passing a String parameter:

var
  S: AnsiString;
begin
  MessageBox(0, PChar(S), 'Error', MB_OK);
end;

needs to be corrected to:

var
  S: AnsiString;
begin
  MessageBoxA(0, PAnsiChar(S), 'Error', MB_OK);
end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!