Where is this clear "default is false" indication in the docs ?<div><br></div><div>RTTI generation has always been "off" by default (as a project wide setting), unless a class extends a type for which RTTI was previously enabled. But I can't find any reference to _extended_ RTTI being disabled by default.</div>
<div><br></div><div>Note also that another (new) option that is OFF by default is WEAKLINKRTTI. This controls whether methods that are discoverable by RTTI are linked even if not directly used. With this ON, then code that would normally be excluded by the linker, because it is not referenced, will still be linked _just in case_ they may be discovered and invoked at runtime thru RTTI.</div>
<div><br></div><div>i.e. If you have not turned WEAKLINKRTTI *ON* then any method for which RTTI is generated will be linked in, even if never called. I don't see any obviously named project level setting for this, so this directive presumably has to be included in every unit where you wish to suppress this behaviour (and thus cannot be applied to VCL units without jumping through hoops).</div>
<div><br></div><div><br></div><div>With all that in mind, now, try this...</div><div><br></div><div>in XE2... create a new VCL Forms application. You can even check that the "Enable RTTI" project setting is indeed the default FALSE setting if you wish. Now drop a TListBox on the default form (ListBox1). Then add this code to the FormCreate event:<br>
<br></div><div><div>var</div><div> rtti: TRTTIContext;</div><div> lType: TRTTIType;</div><div> lMethods: TArray<TRTTIMethod>;</div><div> lMethod: TRTTIMethod;</div><div>begin</div><div> rtti := TRttiContext.Create;</div>
<div> try</div><div> lType := rtti.GetType(self.ClassType);</div><div> lMethods := lType.GetMethods;</div><div><br></div><div> for lMethod in lMethods do</div><div> ListBox1.Items.Add(lMethod.Name);</div><div>
<br></div><div> finally</div><div> rtti.Free;</div><div> end;</div><div>end;</div></div><div><br></div><div>This will list over 170 methods for TForm1 for which RTTI information exists !</div><div><br></div><div>Do the equivalent thing in a version of Delphi prior to D2010 when this extended RTTI was introduced, and you will get just 1: the FormCreate event handler method itself.</div>
<div><br></div><div>Notice also that even if you add the following directive immediately prior to the TForm1 declaration, you still get the same list of 178 methods, even tho the directive appears to (and should, according to the documentation) disable ALL RTTI for that class:</div>
<div><br></div><div><div> {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS ([])}</div></div><div> TForm1 = class(TForm)</div><div><br></div><div>Whether this is some misunderstanding of how this directive is supposed to work, or a bug in the compiler ignoring the directive (no RTTI declaration of any form appears to make any difference at all), I don't know.</div>
<div><br></div><div>Yes, Unicode will have some impact too but I am pretty sure that the new RTTI features that your code now enjoys (without having asked for it, and presumably without even needing it) are the main source for the sudden increase in EXE size.</div>
<div><br></div><div><br><br><div class="gmail_quote">On 17 January 2012 10:33, Peter Hyde <span dir="ltr"><<a href="mailto:peter@webcentre.co.nz">peter@webcentre.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
re: RTTI<br>
<br>
> imho this sort of change should be opt-IN, not opt-OUT.<br>
<br>
XE2 help clearly says the defaut is false, and that's the case for the three projects I'm<br>
working on at present. So the bloat that John reports must come from other factors.<br>
<br>
I think it must be related to the Unicode (or similar) changes as, for my apps at least, the big<br>
increment - about 70% - came in the shift from D2007 to D2010.<br>
<br>
Even so, there was a noticeable (20%) jump between D2010 and XE2.<br>
<br>
cheers,<br>
peter<br>
<br>
<br>
_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br>
</blockquote></div><br></div>