Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!bbn.com!nic!chaos.cs.brandeis.edu!chaos!phils From: phils@chaos.cs.brandeis.edu (Phil Shapiro) Newsgroups: comp.sys.mac.programmer Subject: Re: "bus error" on GetPort Message-ID: Date: 6 Nov 90 15:10:51 GMT References: <85692@tut.cis.ohio-state.edu> Sender: @chaos.cs.brandeis.edu Distribution: usa Organization: Symantec Corp. Lines: 36 In-Reply-To: brown-t@carp.cis.ohio-state.edu's message of 6 Nov 90 00:43:07 GMT In article <85692@tut.cis.ohio-state.edu> 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); } What you really want to do here is: GetPort(&window); Since GetPort() expects a VAR parameter, you must pass the WindowPtr by address. The reason it worked on some computers is because you were storing your WindowPtr to a random place in memory that happened to be even and (apparently) unused. You might want to check out "MacProto.h" header file, it contains prototypes for most Mac Toolbox calls, and would catch mistakes like the above. It's available from most ftp sites. -phil -- Phil Shapiro Technical Support Analyst Language Products Group Symantec Corporation Internet: phils@chaos.cs.brandeis.edu