[fpc-devel] RTTI is always enabled??
Graeme Geldenhuys
graemeg.lists at gmail.com
Thu Dec 10 11:01:47 CET 2009
Hi,
This is a odd one (at least for me and another developer in tiOPF project).
Why is RTTI information ALWAYS available?
See the example project below. It always returns that RTTI information is
available when clearly it should not.
Kylix 3 help says that ClassInfo property should return nil if no RTTI is
available. Tested with FPC 2.4.0-rc1, the test project below always prints
that RTTI is available - which is wrong.
-------------------------------------------
program TestProject;
{$MODE objfpc}{$H+}
var
TestObject: TObject;
function tiHasRTTI(AClass: TClass): Boolean;
var
lClassInfo: Pointer;
begin
lClassInfo := AClass.ClassInfo;
Result := lClassInfo <> nil;
end;
function tiHasRTTI(AObject: TObject): Boolean;
var
lClass: TClass;
begin
lClass := AObject.ClassType;
Result := tiHasRTTI(lClass);
end;
begin
TestObject := TObject.Create;
if tiHasRTTI(TObject) then
WriteLn('Class with RTTI.') // always true???
else
WriteLn('Class without RTTI');
if tiHasRTTI(TestObject) then
WriteLn('Object with RTTI.') // always true???
else
WriteLn('Object without RTTI');
WriteLn;
WriteLn('Press enter to exit.');
ReadLn;
TestObject.Free;
end.
--------------------------------------------
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/
More information about the fpc-devel
mailing list