Am 31.12.2016 16:28 schrieb "Bart" <bartjun...@gmail.com>: > > Hi, > > Why is it that type helpers must be declared in the Interface section > of a unit and cannot be private in Implementation section? > > Consider this (useless) example: > > unit thtest; > > {$mode objfpc}{$H+} > {$modeswitch typehelpers} > > interface > > type > TSomeType = record end; > TA = Array of TSomeType; > > { TAHelper } > > TAHelper = type helper for TA > constructor Create(A: TA); > procedure DoIt; > end; > > procedure X; > > implementation > > procedure X; > var > A: TA; > begin > A.DoIt; > end; > > { TAHelper } > > constructor TAHelper.Create(A: TA); > begin > Self := A; > end; > > procedure TAHelper.DoIt; > begin > ; > end; > > end. > > This compiles fine. > But when you move the declaration of TAHelper to the implementation > section, then you get a compiler error: > > thtest.pp(21,5) Fatal: Syntax error, "CREATE" expected but "DOIT" found > Line 21 is > A.DoIt; > > I'm using fpc 3.0.0 (32-bit) on Windows.
You did put the helper declaration before the implementation of X, right? If you still have a problem, please open a bug report with an example (cause that should definitely work). Regards, Sven
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal