d88-jwa@nada.kth.se (Jon W{tte) (07/13/89)
So, I occationally use LSC 3.01 here at school. What I try to do this time is this: typedef struct { void (* proc1)(); void (* proc2)(); void (* proc3)(); } ptrArry, * ptrP; ptrP foo, bar; ptrArray dis; void doBeep() { SysBeep(1); } main() { foo = &dis; foo->proc2 = doBeep; (* foo)(); /* Up to this point, no problem */ /* Now for the strange part */ bar = foo; (* bar)(); /* And here it cores */ } Using the debugger tells me that after bar = foo both foo and bar contains the same adress. Using MacsBug tells me that they do, as well as tells me that foo->proc2 is the adress to doBeep. BUT, the debugger tells me that bar->proc2 contains.... Surprise! 0x000000 !!!! MacsBug tells me that bar (identical to foo) ->proc2 is 0x0ABC80 (or whatever)... What to do ? What to think ? *(&(foo->proc2)) yields 0x000000 while foo->proc2 yields the correct address. Help me, 'cause I've spent two nights crying in my girlfriends lap over this one... :-) (Well, almost. She doesn't understand it either, and neither do anyone I've asked here) Oh, by the way, these aren't the actual structs and things, but close enough. I haven't the code handy, and It's too large anyway. If you mail me I'll summarize. Happy hacking ! -- __ Jon W{tte (The dread Smiley Shark) email:h+@nada.kth.se / \ (+46 (0) 8 258 268) /--- (c) 1989 Yessbox Allright Professional Products Inc. - Y.A.P.P.I. / -- No More --