[comp.sys.mac.programmer] 72 Extra Bytes of Globals?

ralphm@portia.Stanford.EDU (Ralph Melton) (11/06/90)

Can someone wise in the ways of Think Pascal 3.0 tell me what's happening to
me?

I'm attempting to create an After Dark module in Think Pascal 3.0.  An After
Dark Module depends on a code resource of type 'ADgm'.  When I attempt to
build my code resource, I get an error message that says "Too many global
variables; you have 72 bytes of globals, you can only have 0." I understand
why code resources can't have globals.  My qualm with  Think's error message
is that, to the best of my understanding, I don't have any global variables.
I've checked with the "Find..." command; every incidence of the three letters
"var" occurs in either a parameter list, a local variable declaration, or
a comment.

My sole hypothesis is that I am getting these troubles because I am using
Object Pascal (not the Think Class Library).  After Dark passes the graphics
module a handle, which the module can use as it pleases; I'm using it as
an object reference to an object that does the drawing.  I hypothesize thusly
because I earlier wrote a module without objects that compiled without
problems and is currently running.

Is this correct?  Does the use of objects demand global variables?  I hugely
hope not, because objects are the really excellent way to do what I want
to do, and casing on tag fields of variant records would be a huge hassle.

Any help would be gratefully appreciated.

Ralph Melton
-- 
 
Ralph Melton
ralphm@portia.stanford.edu

phils@chaos.cs.brandeis.edu (Phil Shapiro) (11/06/90)

In article <1990Nov5.184017.17820@portia.Stanford.EDU> ralphm@portia.Stanford.EDU (Ralph Melton) writes:
   [ ... a problem with 72 bytes of globals in a code resource ... ]

   My sole hypothesis is that I am getting these troubles because I am
   using Object Pascal (not the Think Class Library).  [ ... ]

   Is this correct?  Does the use of objects demand global variables?
   I hugely hope not, because objects are the really excellent way to
   do what I want to do, and casing on tag fields of variant records
   would be a huge hassle.

Your hypothesis is correct.  Objects (in both Think Pascal and Think
C) use global (A5) offsets to dispatch to their methods.  Also, each
object uses some global space for storing other information.  In ThC,
this isn't a problem since it allows globals and provides a fake jump
table (all referenced off of A4).

There isn't any way that I know of around this problem.

One note: the actual error you got was from using the Pascal procedure
new(), not from using objects.

	-phil
--
   Phil Shapiro                           Technical Support Analyst
   Language Products Group                     Symantec Corporation
		Internet: phils@chaos.cs.brandeis.edu