Thanks for the advices.

Quote Originally Posted by Chebmaster View Post
My advice would be to define your own AllegroString and use it everywhere, the definition itself wrapped in conditionals for different compilers/platforms.
Quote Originally Posted by de_jean_7777 View Post
I also do what Chebmaster does. Define my own StdString type which is currently UnicodeString, and convert in abstract platform routines. In your case your own type would be ansistring due to the Allegro library.
Actually I defined two types for Allegro.pas yet: AL_STR which is ANSISTRING, and AL_STRptr which is PCHAR (or PANSICHAR depending the compiler). That solves part of the problem.

It is using Delphi's RTL where I have problems. For example, to draw the score on screen I may use this:
Code:
  al_draw_text (aFont, aColor, aXpos, aYpos, 0, Format ('SCORE: %d', [aScore]));
This works perfect in FPC but shows a warning in Delphi. Note that it actually renders the text (except in a few Allegro functions) but the warning is pretty annoying. I know I can avoid it using conversion functions as I've explained above but they aren't needed by FPC (actually they'll not work!).

Quote Originally Posted by pitfiend View Post
I think you can define some compile time arguments. Those that controls how strings are managed.
$X+ $X- Extended Syntax, this one makes Delphi strings PChar compatible. Also allows you to use functions as procedures ignoring results
$H+ $H- Long Strings, this one turns on/off UnicodeString. Can be used locally to set strings to old Delphi behavior.
$V+ $V- This one is useful with shortstrings only as it allows you to give any sized strings as parameter when set as $V-. If you set it to $V+ then you need to pass strict string types.
This are mainly backward compatibility options. Be careful, unexpected results may happen.

Another trick you can use, is to define a local string type after detecting if Delphi or Free Pascal, and use it as you need in every parameter you pass.
I didn't know about $X and $V arguments. Anyway I did some testing and I didn't find they helps.

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.

I think I should add conditional compilation in the examples (they're only a few that conficts) or write different examples for FPC and Delphi for such cases.