【Objective_C学习笔记】Debug表达方式

  经常在源码中看到类似于如此定义debug模式

#if DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"\nfunction:%s line:%d\n%s\n", __FUNCTION__, __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#endif

其中对那些__FUCTION__, __LINE__宏不知道代表什么,网上查看资料

http://blog.csdn.net/fullsail/article/details/2345225#comments

http://onevcat.com/2011/12/debug-2/

https://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Function-Names.html

http://stackoverflow.com/questions/4434282/visual-c-equivalent-of-file-line-and-pretty-function

  • __FUCTION__ 函数提供类名和函数名称的输出;
  • __LINE__函数提供行号的输出;
  • __FILE__函数提供文件目录的输出;
  • __PRETTY_FUNCTION__函数, <return-type>  <class-name>::<member-function-name>(<parameters-list>) 的格式输出成员函数的详悉信息(只会输出parameters-list的形参类型而不会输出形参名).若用gcc编译C程序,__PRETTY_FUNCTION____FUNCTION__的功能相同

这些对日志跟踪很有用。

posted @ 2015-12-08 18:01  风语菡  阅读(148)  评论(0编辑  收藏  举报