ADC Home > Reference Library > Technical Q&As > Legacy Documents > Mac OS 9 & Earlier >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

NewRoutineDescriptor & Porting 68K code to PPC


Q: I'm trying to port my 68K code to PPC. I have custom functions defined for calling ModalDialog. Here's what my code looked like:

ModalDialog((ModalFilterProcPtr) MyFilter, &itemNum);

The compiler complained that it cannot covert my custom function to type RoutineDescriptor*, so I changed it by casting it to RoutineDescriptor:

ModalDialog((RoutineDescriptor*) MyFilter, &itemNum);

There were no compile or link errors, but now, when I run the program, it crashes with a type 3 error.

What's the correct way to implement this?

A: Create a UPP using NewRoutineDescriptor instead of casting to a UPP. In Dialogs.h there is a macro for NewRoutineDescriptor called NewModalFilterProc. Your code should look like this:

ModalFilterUPP myFilterUPP;
myFilterUPP = NewModalFilterProc(MyFilter);
ModalDialog(myFilterUPP,  &itemNum);

See Also

  • See Using Universal Procedure Pointers in Inside Macintosh: PPC System Software, page 2-21, for more information.

[Jun 01 1996]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.