On Tue, 2004-08-17 at 08:05, kcorey wrote:
> On Mon, 2004-08-16 at 18:35, Ben Combee wrote:
> > >Off the top of my head, I think you have to select the variable, go to the 
> > >Expressions tab in the Debug view, right click on it, and select Add New 
> > >Expression.  I also think that this works only when the application is 
> > >stopped in the debugger.
> > >
> > >I agree that this is awkward, but its part of the base CDT 
> > >functionality.  We've got a request in to the core CDT team to see about 
> > >fixing this (if it hasn't already been done for CDT 2.0 -- I haven't 
> > >checked yet).
> > 
> > A test case I just tried didn't work with the release build of PODS 
> > 1.0.  When I went to the expressions window and did "add global variable", 
> > there were no items on the list, even though I had both an external and 
> > static globals that were referenced in my code.  Like Ken saw, local 
> > variables were visible.
> 
> It's a relief that I wasn't a complete boob!
> 
> It is a bit frustrating, though, considering how much global variables
> are used in regular C palm programming.
> 
> Ah well.  I can tell the promise this tool shows.  Please keep up the
> good work, guys!
> 
> I guess I could have a data structure that holds all my global
> variables, and use it to pass the global structure as an argument to all
> functions.  (ack!)

Actually, it's a bit easier than I'd expected.  Put all your globals
into a struct like this:

struct globs {
  // All my globals
  int globX;
} globs;

Then I can refer to them from within functions like this:

int test(parmlist...)
{
        struct globs *g=&globs;

        g->globX = somevalue;
}

So, it's a work-around that doesn't require me to redefine all my
function calls.  It also has the benefit that all my globals are in a
nice neat package for dropping into a database for saving state between
invocations.  Hows that for looking at the bright side?

There's a bit of a wrinkle I noticed in my 3 minutes of playing with
this...

If you define this:

struct globs {
        int globX;
        int test[100];
} globs;

And then view this from within a function while debugging, apparently
the array test is not dereferenced correctly.  It's displayed as if it
were another struct globs rather than int[];  Curious, eh?

-Ken


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to