Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: "bus error" on GetPort Message-ID: <11153@goofy.Apple.COM> Date: 7 Nov 90 01:38:15 GMT References: <85692@tut.cis.ohio-state.edu> Distribution: usa Organization: Apple Computer Inc., Cupertino, CA Lines: 43 hairston@henry.ece.cmu.edu (David Hairston) writes: >[brown-t@carp.cis.ohio-state.edu (ted croft brown) writes:] >[] I have come across a probelem that has me REALLY confused. I am >[] programming in THINK C 4.02. I am in the process of writting my first >[] Macintosh C program (and it's been *educational*). >[] >[] Anyway, in writting Modal dialogs I do... >[] >[] HandleMenuCommand() >[] { >[] WindowPtr window >[] >[] . >[] . >[] GetPort(window); >[] DoDialogRoutine(); >[] SetPort(window); >[] } >[] >[] My code runs at home on my Mac SE (1 MB) but not on the > >hmm, altho taking the address of a pointer might seem strange at >first thought, you need to pass the address of "window" to GetPort, >as in: GetPort(&window); >where it's value will get set correctly. don't know why this >would work on one machine and not another (seems like the example >should always fail). On Macs prior to the IIci, RAM addresses were allowed to wrap even though there was no physical RAM filling up the entire space. Starting with the IIci, the MMU is setup so that you can only read/write to the actual RAM, and if you go past it, it'll bus error on you. More than likely, the "pointer" that's being passed to GetPort falls into that range of RAM addresses that don't really exist... steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ whoami? Steve Christensen snail: Apple Computer, 20525 Mariani Ave, MS-81CS, Cupertino, CA 95014 Internet: stevec@apple.com AppleLink: stevec CompuServe: 76174,1712