[fpc-devel] Strange problem with -M and -S command-line options
Aleksa Todorovic
alexione at gmail.com
Mon Sep 22 13:57:26 CEST 2008
Hi!
I've just hit this problem, and wanted to report it, so someone can
tell me if this is FPC or Lazarus bug.
==================
Compiler version: 2.2.2
Lazarus version: svn trunk (revision 16671)
Description: If -Sh is used before -Mobjfpc on command-line, string is
interpreted as ShortString, not AnsiString.
Usage problem: The latest version of Lazarus generates command-line
with -Sh option before -Mobjfpc.
Reproducability: Always
==================
program test_string;
var
s1: AnsiString;
s2: string;
begin
s1 := 's1';
WriteLn('s1 = ', s1, ' : ', SizeOf(s1));
s2 := 's2';
WriteLn('s2 = ', s2, ' : ', SizeOf(s2));
end.
==================
TEST RUN 1
Command-line: fpc -Mobjfpc test_string.pas
Output:
s1 = s1 : 4
s2 = s2 : 256
==================
TEST RUN 2
Command-line: fpc -Mobjfpc -Sh test_string.pas
Output:
s1 = s1 : 4
s2 = s2 : 4
==================
TEST RUN 3
Command-line: fpc -Sh -Mobjfpc test_string.pas
Output:
s1 = s1 : 4
s2 = s2 : 256
==================
As you can see, in the third case string is interpreted as
ShortString, not AnsiString. Is this intended behaviour of compiler,
or command-line processing bug?
Best,
Aleksa
More information about the fpc-devel
mailing list