string in variant array is cropped?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

string in variant array is cropped?

Bee-6
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



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: generated exe file size

Bee-6
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


----- Original Message -----
From: "Bisma Jayadi" <[hidden email]>
To: <[hidden email]>
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



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: generated exe file size

Jonas Maebe

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.


Jonas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: generated exe file size

Marco van de Voort
> 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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal