[fpc-devel] {$M+} and forward declarations do not work

Graeme Geldenhuys graemeg at opensoft.homeip.net
Tue Dec 20 09:08:33 CET 2005


And this is the error I get:

C:\Programming\Tests\GetPropList\Laz2>project1.exe
An unhandled exception occurred at $0043AAEB :
EAccessViolation : Access violation
   $0043AAEB  GETTYPEDATA,  line 478 of ../objpas/typinfo.pp
   $0043AFF1  GETPROPLIST,  line 683 of ../objpas/typinfo.pp
   $004010BA  SHOWPROPERTIES,  line 46 of 
C:/Programming/Tests/GetPropList/Laz2/p
roject1.pas


Again, running FPC 2.0.1 that came with Lazarus 0.9.10 on Windows 2000.

G.



Graeme Geldenhuys wrote:
> 
> Here is the command line version of my app.
> 
> ------------------------------------------------------
> program project1;
> 
> {$mode objfpc}{$H+}
> 
> uses
>   Classes, SysUtils, TypInfo;
> 
> 
> type
> {$M+}
>   TMyTestObject = class;
> {$M-}
> 
> 
>   TSomeOtherClass = class(TObject)
>   private
>      FName: string;
>   public
>     property Name: string read FName write FName;
>   end;
> 
> 
>   TMyTestObject = class(TObject)
>   private
>      FIntProp: integer;
>      FStringProp: string;
>   public
>   published
>     property StringProp: string read FStringProp write FStringProp;
>     property IntProp: integer read FIntProp write FIntProp;
>   end;
> 
> 
> procedure ShowProperties;
> var
>   O: TMyTestObject;
>   i: Longint;
>   lPropFilter: TTypeKinds;
>   lCount: Longint;
>   lSize: Integer;
>   lList: PPropList;
> begin
>   O := TMyTestObject.Create;
>   lPropFilter := [tkInteger, tkAString];
> 
>   lCount  := GetPropList(O.ClassInfo, lPropFilter, nil, false);
>   lSize   := lCount * SizeOf(Pointer);
>   GetMem(lList, lSize);
> 
>   Writeln('Total property Count: ' + IntToStr(lCount));
>   lCount := GetPropList(O.ClassInfo, lPropFilter, lList, false);
>   for i := 0 to lCount-1 do
>   begin
>     Writeln('Property '+IntToStr(i+1)+': ' + lList^[i]^.Name);
>   end;
> 
>   FreeMem(lList);
>   O.Free;
>   Writeln('---------------');
> end;
> 
> 
> begin
>   ShowProperties;
> end.
> 
> ------------------------------------------------------
> 
> Regards,
>   - Graeme -
> 
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
> 
> 





More information about the fpc-devel mailing list