__PRETTY_FUNCTION__ does that. I have this in my Prefix.pch:
#ifdef DEBUG // DLOG takes a format argument (which must begin %s) and 0 or more args: // DLOG(@"%s"); // DLOG(@"%s: %d", x); #define DLOG(fmt, ...) NSLog(fmt, __PRETTY_FUNCTION__, ##__VA_ARGS__) #else #define DLOG(...) #endif
If you're to lazy to write __PRETTY_FUNCTION__. You can just write __func__. It does the same. http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Function-Names.html
3 comments:
__PRETTY_FUNCTION__ does that. I have this in my Prefix.pch:
#ifdef DEBUG
// DLOG takes a format argument (which must begin %s) and 0 or more args:
// DLOG(@"%s");
// DLOG(@"%s: %d", x);
#define DLOG(fmt, ...) NSLog(fmt, __PRETTY_FUNCTION__, ##__VA_ARGS__)
#else
#define DLOG(...)
#endif
Thanks for the tip, Mark. I hadn't known about __PRETTY_FUNCTION__.
If you're to lazy to write __PRETTY_FUNCTION__. You can just write __func__. It does the same. http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Function-Names.html
Post a Comment