Exactly.
The CALLBACK_PROLOGUE macro inserts some assembly code into your file. It
*must* be the first statement in the function. When you use locals that are
initialized in the declaration section, its as if you did this:
***You Say:
static void TableCustomDraw (VoidPtr table, Word row, Word column,
RectanglePtr bounds)
{
UInt CurrDisplayRec = topIdx + row - 1;
CALLBACK_PROLOGUE
***Compiler Says:
static void TableCustomDraw (VoidPtr table, Word row, Word column,
RectanglePtr bounds)
{
UInt CurrDisplayRec;
CurrDisplayRec = topIdx + row - 1;
CALLBACK_PROLOGUE
Obviously, this is bad.
Here's another way around it, which is pretty much OK:
static void TableCustomDraw (VoidPtr table, Word row, Word column,
RectanglePtr bounds)
{
CALLBACK_PROLOGUE
{
UInt CurrDisplayRec = topIdx + row - 1;
// rest of fn
}
CALLBACK_EPILOGUE
}
In other words, always put the pro/epis right inside the fn braces, and then
include another pair of nested braces where you code your function.
- John Schettino
Palm OS Programming for Dummies: http://schettino.tripod.com
-----Original Message-----
From: Jens Rupp [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 08, 2000 10:59 AM
To: Palm Developer Forum
Subject: Re: Variable Initialization madness
Hi
a educated guess...
> Here the fun starts - Why is the following such a big difference ?:
>
> This one doesn't work
> ##################
> static void TableCustomDraw (VoidPtr table, Word row, Word column,
> RectanglePtr bounds)
> {
> UInt CurrDisplayRec = topIdx + row - 1;
> CALLBACK_PROLOGUE
> ....
This has some code *before * the CALLBACK_PROLOGUE macro which ensures that
global var (topIdx) access works.
> This one DOES work - WWWHHHYYY ???
> ####################################
> static void TableCustomDraw (VoidPtr table, Word row, Word column,
> RectanglePtr bounds)
> {
> UInt CurrDisplayRec;
> CALLBACK_PROLOGUE
> CurrDisplayRec = topPatientIdx + row - 1;
> ....
This has the code moved behind the macro
You were lucky the first did work at all on some os versions.
Jens
-------------------------------------------
Jens Rupp
[EMAIL PROTECTED]
www.gacel.de
www.pocketreport.com
Ircnet: Gacel
-------------------------------------------
"Ein Buch das man liebt, darf man nicht leihen, sondern mu� es besitzen".
Friedrich Nietzsche
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html