Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-05

string in variant array is cropped?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bisma Jayadi

Hi all,

I never playing around with variant using FPC before, until last night. :D Currently I'm using FPC 2.0.0 (downloaded from SF) on Pentium III with WinXP SP 2.

I found a strange behavior of string in FPC variant array. Unfortunately, I hardly can find good enough informations about variant in FPC docs. There's no chapter about it in the RTL doc, though the Variants unit does exist. So, I assume FPC variant is just like Delphi variant. :)

Here is the code...

---------

 1: program VarTest;
 2:
 3: {$APPTYPE CONSOLE}
 4:
 5: uses
 6:   Variants;
 7:
 8: var
 9:   v: Variant;
10:
11: begin
12:   // this works fine
13:   v := 'abcdefghijklmnopqrstuvwxyz';
14:   Writeln(v);
15:
16:   // this variant array works but all
17:   // the strings content are cropped
18:   v := VarArrayCreate([0,6], varVariant);
19:   v[0] := 1;
20:   v[1] := 123.4;
21:   v[2] := 'abcdefghijklmnopqrstuvwxyz';
22:   v[3] := true;
23:   v[4] := vararrayof([1,2,3,4]);
24:   v[5] := 'abcdefghijklmnopqrstuvwxyz';
25:   v[6] := 'abcdefghijklmnopqrstuvwxyz';
26:   writeln(v[0]);
27:   writeln(v[1]);
28:   writeln(v[2]);
29:   writeln(v[3]);
30:   writeln(v[4][2]);
31:   writeln(v[5]);
32:   writeln(v[6]);
33: end.

---------

And the program output is...

---------

� Free Pascal IDE Version 1.0.4 [2005/05/08]
� Compiler Version 2.0.0
� GBD Version GDB 6.2.1
� Cygwin "C:\Programs\FreePascal\bin\i386-win32\cygwin1.dll" version 1005.12.0.0
Running "c:\trash\vartest.exe "
1: abcdefghijklmnopqrstuvwxyz
2: 1
3: 123,40000000000001
4: abcdefghijklm
5: True
6: 3
7: abcdefghijklm
8: abcdefghijklm

---------

while the same code compiled using Delphi 7 generates output like this...

---------

C:\Trash>vartest.exe
1: abcdefghijklmnopqrstuvwxyz
2: 1
3: 123,4
4: abcdefghijklmnopqrstuvwxyz
5: True
6: 3
7: abcdefghijklmnopqrstuvwxyz
8: abcdefghijklmnopqrstuvwxyz

---------

See what I meant? They're on output line number 4, 7, and 8. And also on number 3 (floating number). While the code is compiled using FPC, switching compilation mode to FPC, or OBJFPC, or Delphi, will have same output result.

So... is there any explanation about this? Thanks.

-Bee-

has Bee.ography at:
http://beeography.modblog.com

Reply by email

Bisma Jayadi
to Bisma Jayadi

And one more thing...

The code is compiled using FPC with faster code optimization, generate exe file with size 435 KB. While it is compiled using Delphi with optimization, generate exe file with size (only) 83 KB. Why FPC generate that so big exe file? I only use Variants unit explicitely.

-Bee-

has Bee.ography at:
http://beeography.modblog.com

Earlier message 21 lines
----- Original Message ----- From: "Bisma Jayadi" To: Sent: Thursday, 26 May 2005 10:27 Subject: [fpc-pascal] string in variant array is cropped? > Hi all, > > I never playing around with variant using FPC before, until last night. :D > Currently I'm using FPC 2.0.0 (downloaded from SF) on Pentium III with WinXP > SP 2. > > ----->8-----deleted----->8----- > > So... is there any explanation about this? Thanks. > > -Bee- > > has Bee.ography at: > http://beeography.modblog.com

Reply by email

Jonas Maebe
to Bisma Jayadi
Bisma Jayadi wrote 7 lines
The code is compiled using FPC with faster code optimization, generate exe file with size 435 KB. While it is compiled using Delphi with optimization, generate exe file with size (only) 83 KB. Why FPC generate that so big exe file? I only use Variants unit explicitely.

Make sure you turn on smart linking (-XX). Also, stripping of debug information is broken in the current versions of the GNU linker, which we use. We cannot help that, and older versions in which this does work cannot link with certain libraries.

Jonas

Reply by email

Marco van de Voort
to Jonas Maebe
Show quoted text 14 lines
On 26 mei 2005, at 05:44, Bisma Jayadi wrote: > The code is compiled using FPC with faster code optimization, generate > exe file > with size 435 KB. While it is compiled using Delphi with optimization, > generate > exe file with size (only) 83 KB. Why FPC generate that so big exe > file? I only > use Variants unit explicitely. Make sure you turn on smart linking (-XX). Also, stripping of debug information is broken in the current versions of the GNU linker, which we use. We cannot help that, and older versions in which this does work cannot link with certain libraries.

Note that stripping debuginfo via the "strip" utility works, at least better than via ld.

Reply by email