Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!aplcen!haven!umd5!zben From: zben@umd5.umd.edu (Ben Cranston) Newsgroups: comp.sys.mac.programmer Subject: Re: Low memory globals from C (Was RE: Finding Screensize under MF) Summary: Why shouldn't *.h be coded with *(blap*0xXXX) syntax? Message-ID: <5951@umd5.umd.edu> Date: 16 Jan 90 01:51:46 GMT References: <10139@saturn.ucsc.edu> <9429@hoptoad.uucp> <1102@urbana.mcd.mot.com> <10276@saturn.ucsc.edu> <9623@hoptoad.uucp> <4615@helios.ee.lbl.gov> Reply-To: zben@umd5.umd.edu (Ben Cranston) Organization: University of Maryland, College Park Lines: 52 In article <9623@hoptoad.uucp> tim@hoptoad.uucp (Tim Maroney) writes: > To access low-memory globals from C, if you must, you use the macro > preprocessor. For instance, you would say > #define CurrentA5 (*(long *)0x904) In article <4615@helios.ee.lbl.gov> beard@ux1.lbl.gov (Patrick C Beard) writes: > A cleaner way to do low memory globals from THINK C is the ':' notation. > extern Ptr CurrentA5 : 0x904; > This method gives you do type checking if you want. While the ':' notation is very clean and would be nice to have in MPW someday, can anybody see a reason why the equates in the various *.h files could not simply be in C access format: in frump.h: #define FrumpCount *(short *) 0x1234; in user code #include FrumpCount = 0; /* fudge system global */ as it stands now, the equates are just to the numbers and the user program must supply the cast: in frump.h: #define FrumpCount 0x1234; in user code #include *(short * FrumpCount) = 0; In other words, can anybody see a profitable use for the address as a plain integer rather than a cast item? Actually, one could probably recover the integer for most purposes simply by using the &FrumpCount construct... (except for compile time values with stupid compilers). Is there any reason for using the simple number equates other than a bad case of assembly language hangover? (utmost apologies to whatever actually lives at 0x1234...) -- Sig DS.L ('ZBen') ; Ben Cranston * Network Infrastructures Group, Computer Science Center * University of Maryland at College Park * of Ulm