hartkopf@spot.Colorado.EDU (Jeff Hartkopf) (05/11/91)
Is there anything weird to know about the stack when using code resources? I ask because I'm having some strange problems using them from an NDA and I'm not sure what's causing the problems. Here's what I'm doing and what's going wrong: I write the code resource function with ORCA/C, and it takes several various sized parameters (ints, pointers, etc.). I then copy the compiled and linked function into my resource fork using the Genesys Import option. In my NDA (also written with ORCA/C) I do the required stuff to load the code resource, lock it in place, and call it. Generally the call to the code resource function works smoothly. However, sometimes if I change the number of parameters to the code resource function, or add or take away some local variables in the code resource function, some things don't work quite right. Sometimes the function's return value isn't returned properly (e.g., I return an int value 0 but get back a garbage value). Other times if I modify the contents of a variable pointed to by a pointer parameter to the function, it doesn't get modified properly. Usually, adding a new local variable or parameter to the function fixes the problem. So it seems like the problem has something to do with the stack getting messed up. Very strange problem. Any ideas, anyone? Thanks! Jeff Hartkopf University of Colorado at Boulder Internet: hartkopf@spot.colorado.edu
dlyons@Apple.COM (David A. Lyons) (05/11/91)
In article <1991May11.022741.25916@colorado.edu> hartkopf@spot.Colorado.EDU (Jeff Hartkopf) writes: >Is there anything weird to know about the stack when using code resources? Nope, once you've got your resource loaded into memory, it's just code. Any weirdness going on must be because of a misunderstanding between the routine and the caller about how parameters are being passed. How are you calling the code resource from C? I especially want to see the function itself, its declaration in the file you are calling it from, and the expression that actually calls it. Perhaps you've declared the routine as "pascal" style in one place but not the other? -- David A. Lyons, Apple Computer, Inc. | DAL Systems Apple II System Software Engineer | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie:DAVE.LYONS CompuServe:72177,3233 Internet:dlyons@apple.com My opinions are my own, not Apple's.