You can directly write enums with Write or WriteLn and convert enums
to strings with WriteStr.
program EnumStr;
{$mode objfpc}{$H+}
type
TColor = (cRed, cGreen, cBlue, cYellow);
function ColorToStr(C: TColor) : String;
begin
WriteStr(Result, C);
end;
var
Color : TColor;
begin
for Color
2011/9/7 Leonardo M. Ramé :
> From: Yann Bat
>
>
> The error message is correct, because inside the scope of method Bug, _T
> points to nil, and the size of nil is 0, so 1 div 0 raises the error.
>
I think that SizeOf(_T) should be unknown rather than 0. The compiler
s
Thanks. You've just found bug number 3 ! :-)
But #1 and #2 are alway here.
2011/9/7 Marco van de Voort :
> In our previous episode, Yann Bat said:
>> I am trying to learn freepascal generics and I think that I have found 2
>> bugs.
>
>> var
>> V:
Hi,
I am trying to learn freepascal generics and I think that I have found 2 bugs.
Tested with FPC 2.4.4 Linux x86
==
= BUG 1 - with SizeOf =
==
program SizeOfBug;
{$mode objfpc}{$H+}
type
generic TGen<_T> = class(TObject)
private
FField: _T;
publ
2010/10/11 Michael Van Canneyt :
>
> Please enter a bug report for this.
>
Done.
http://mantis.freepascal.org/view.php?id=17604
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Hi,
I think I have found a bug in FPC 2.4.0. Tested under Windows XP 32
bits and Linux 32 bits.
program TestLength;
begin
WriteLn('L =', Length('') );
end.
This program gives L = 1 but I think it should give L = 0.
Is this really a bug ? Can you reproduce this ?
Thanks
__
> It is allowed in Delphi and TP because they allow declaring typed constants
> of objects.
Exactly what I wanted to use. I'll have to use constructors so.
Thank you for your help.
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://list
> The compiler always adds a VMT if an object has a constructor or destructor.
> The reason is that the VMT also contains the instance size, which is used by
> the constructor helper to allocate the required amount of memory.
>
Ok but why a different behaviour between [fpc | objfpc] mode and [tp
Hi,
I don't understand why compilation of the program below failed in fpc
and objfpc mode. In tp and delphi mode it works as expected but in fpc
and objfpc mode the compiler complains :
blob.pas(17,3) Error: Constants of objects containing a VMT aren't allowed
blob.pas(17,3) Fatal: Syntax err
Please forgot my stupid question.
GetMem works perfectly as described in the documentation. My problem
cames from an another part of my program.
Yann
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinf
Hi,
I'm looking for a function or a procedure that tries to allocate
memory and return nil on failure.
GetMem seems to be a good candidate but it doesn't works as expected.
The FreePascal documentations
(http://www.freepascal.org/docs-html/rtl/system/getmem.html) tells
that it returns nil on fail
11 matches
Mail list logo