GNU Pascal and warnings.
Frank Heckenbach
ih8mj at fjf.gnu.de
Wed Feb 18 18:31:20 CET 2009
Lennart Thelander wrote:
> For quite many functions/Procedures, I get two warnings:
> warning: frame size too large for reliable stack checking
> warning: try reducing the number of local variables
>
> Say what? Reducing the number of local variables? Here's an example:
>
> PROCEDURE TTextEditItem.HandleKey(VAR theEvent:EventRecord);
> VAR
> i : SInt16;
> pt : Point;
> theChr : Char;
> theKey : SInt16;
> shift : BOOLEAN;
> option : BOOLEAN;
> control : BOOLEAN;
> command : BOOLEAN;
> lineHeight,
> ascent : SInt16;
> theStyle : TextStyle;
>
> I say that's a small amount of (small) local variables, so how can there be
> too many?
The word "number" is a bit misleading, it's actually about the total
size. Perhaps TextStyle is a larger structure here. It might also be
an implicit temporary variable created by the compiler. E.g., some
string and set operations need them.
> And what is a "frame"
The space on the stack to contain the local variables, parameters
etc. of a routine call.
> and how can I reduce its size?
If it's an explicit variable, you could make it a pointer (though
you might not want to for good reasons). For implicit variables, you
cannot do this easily without rewriting the code.
> Or better: How do I
> allow for a larger frame size?
AFAIK, on affected platforms (mainly Mac OS X), it cannot be
changed. However, the warning only refers to the stack checking
option, i.e., the code with the larger frame size will work fine by
itself, just without stack checking.
See also:
http://www.gnu-pascal.de/crystal/gpc/de/mail7971.html
http://www.gnu-pascal.de/crystal/gpc/de/mail13595.html
Frank
--
Frank Heckenbach, f.heckenbach at fh-soft.de, http://fjf.gnu.de/, 7977168E
GPC To-Do list, latest features, fixed bugs:
http://www.gnu-pascal.de/todo.html
GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8
More information about the Gpc
mailing list