---
title: OSMemberFunctionCast
framework: kernel
role: symbol
role_heading: Macro
path: kernel/osmemberfunctioncast
---

# OSMemberFunctionCast

Converts a C++ member function pointer, relative to an instance, to a C-style pointer to function.

## Declaration

```occ
#define OSMemberFunctionCast(cptrtype, self, func)
```

## Parameters

- `cptrtype`: The function type declaration to cast to (typically provided as a typedef by I/O KitKit classes).
- `self`: The this pointer of the object whose function you wish to cache.
- `func`: The pointer to the member function itself, something like &Class::function.

## Return Value

Return Value A pointer to a function of the given type referencing self.

## Discussion

Discussion This function is used to generate pointers to C++ functions for instances, such that they can be registered as callbacks with I/O Kit objects. No warnings are generated. This function will panic if an attempt is made to call it with a multiply-inheriting class.

## See Also

### Miscellaneous

- [OSCheckTypeInst](kernel/oschecktypeinst.md)
- [OSDynamicCast](kernel/osdynamiccast.md)
- [OSSafeRelease](kernel/ossaferelease.md)
- [OSSafeReleaseNULL](kernel/ossafereleasenull.md)
- [OSTypeAlloc](kernel/ostypealloc.md)
- [OSTypeID](kernel/ostypeid.md)
- [OSTypeIDInst](kernel/ostypeidinst.md)
- [checkTypeInst](kernel/osmetaclassbase/1808042-checktypeinst.md)
- [getMetaClass](kernel/osmetaclassbase/1808051-getmetaclass.md)
- [getRetainCount](kernel/osmetaclassbase/1808060-getretaincount.md)
- [isEqualTo](kernel/osmetaclassbase/1808069-isequalto.md)
- [metaCast(const char *)](kernel/osmetaclassbase/1808075-metacast.md)
- [metaCast(const OSMetaClass *)](kernel/osmetaclassbase/1808082-metacast.md)
- [metaCast(const OSString *)](kernel/osmetaclassbase/1808090-metacast.md)
- [metaCast(const OSSymbol *)](kernel/osmetaclassbase/1808095-metacast.md)
- [release()](kernel/osmetaclassbase/1808103-release.md)
- [release(int)](kernel/osmetaclassbase/1808109-release.md)
- [retain](kernel/osmetaclassbase/1808117-retain.md)
- [safeMetaCast](kernel/osmetaclassbase/1808126-safemetacast.md)
- [serialize](kernel/osmetaclassbase/1808135-serialize.md)
- [taggedRelease(const void *)](kernel/osmetaclassbase/1808142-taggedrelease.md)
- [taggedRelease(const void *, const int)](kernel/osmetaclassbase/1808151-taggedrelease.md)
- [taggedRetain](kernel/osmetaclassbase/1808161-taggedretain.md)
