Using clang and objective-c I am wondering if I can get a printed string describing the type of a potentially null parameter (i.e. compile time information).
For example, something like:
- (void)myFunc:(NSString *)aNilString { NSLog(@"%s", __typeof__(aNilString)); }
Obviously this does not work, because __typeof__ gets me the actual type, not the string. In C ++, we have a typeid that returns std :: type_info, but this name is garbled, for example. "P12NSString *", not "NSString *".
Ideally, I would like something that can be passed to functions like objc_getClass (). Is there a way to get what I want?
Edit: I don't need to compile as C ++, so this solution is missing:
abi::__cxa_demangle(typeid(*aNilString).name(), 0, 0, 0));
source share