-
-
Notifications
You must be signed in to change notification settings - Fork 9
Typenameof
IsaacShelton edited this page Mar 21, 2022
·
1 revision
typenameof can be used to get the name of a compile-time type as a C-String.
typenameof Type
The resulting value will be a *ubyte null-terminated string.
import basics
struct Thing ()
func main {
thing *Thing = null
printNameOfType(thing)
}
func printNameOfType(_something *$T) {
printf("You passed a pointer to %s\n", typenameof $T)
}
You passed a pointer to Thing
As opposed to older methods of using RTTI for the same effect, the usage of typenameof does not require runtime type information to be enabled.