Quote Originally Posted by Ñuño Martínez View Post
The test I did was:
Code:
  procedure TForm1.Button1Click (Sender: TObject);
  VAR
    lText: ANSISTRING;
  begin
    INC (fNum);
    lText := 'Test #%d';
    lText := Format (lText, [fNum]);
    Memo1.Lines.Add (lText)
  end;
Compiled with {$H-}, and also changing the "Long strings by default" to false, but it still shows the warning.
Using your example in modern Delphi versions will always show a warning regardless of what string compiler directives you use in your code. Why? That is because the Format function is always returning default Delphi string type which is WideString, And since you are then assigning it to AnsiString you get a warning.

So you either need to create your own version of Format function that will be returning AnsiString result or disable of using of LongString as default string type at Project Options->Building->Delphi Compiler->Compiling (check Syntax options section).
http://docwiki.embarcadero.com/RADSt...o/en/Compiling
Do note that this affects your entire project so if you have other code parts that are built to work with Unicode string they may stop working properly.