Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!nrl-cmf!cmcl2!rutgers!mcnc!rti!rcb From: rcb@rti.UUCP (Randy Buckland) Newsgroups: comp.sys.mac.programmer Subject: LSC almost gets it right. Message-ID: <2423@rti.UUCP> Date: 1 Sep 88 13:28:51 GMT Reply-To: rcb@rti.UUCP (Randy Buckland) Organization: Research Triangle Institute, RTP, NC Lines: 37 Well, last night I found my first gripe with LSC 3.0. Before that I was perfectly happy with the system. I still like it and I think this problem could be fixed without a great deal of difficulty. I was adding all the standard event handling code to a new program. This is my first C program on the MAC I have written Pascal programs on the MAC and C programs on other machines, so I didn't expect any problem. My problem came with expecting the built-in prototypes for the MAC ROM functions to prevent any mistakes in parameters passing. But apparently, they only check the size of an argument and do not enforce strict type compatability like normal prototypes do. Anyway I had the following lines in my program: Point position; . . GLobalToLocal (position); As is now obvious, position was not passed by reference, but by value. Since the function wanted an address which is 4 bytes and the position structure (2 integers) is 4 bytes, the compiler said ok and just pushed the structure onto the stack. Naturally, this caused all kinds of grief since position contained the current mouse position where the event occured. THe function would merrily take that screen position as an address and convert the value at that address from global coordinates to local coordinates. SInce this was an almost totally random failure mode, it was impossible to track down. I eventually found it by checking the calling sequence for every ROM call in my program. I plan to try to define a real prototype for this function and see if it still allows this kind of error. So Rich, how about an include file from Think that defines real prototypes for all the ROM functions. -- Randy Buckland (919)-541-7103 Research Triangle Institute rcb@rti.rti.org [128.109.139.2] {decvax,ihnp4}!mcnc!rti!rcb