关于c语言#define debug
来源:互联网 发布:centos挂载ntfs硬盘 编辑:程序博客网 时间:2024/06/10 18:50
- C/C++ code
- #include<iostream>using namespace std;#define DEBUGint factorial(int num){if(num == 0)return 1;else{ # if defined(DEBUG)static i;cout << "call times:" << ++i << ",num=" << num <<endl;# endifreturn factorial(num -1) * num;}}int main(){int number;cout << "enter a integer:";cin >> number;cout << "the factorial number:"<< factorial(number)<< endl; return 0;}
其中#define DEBUG 该怎么理解 还有
什么时候 define(DEBUG)就为真了。
答:这是常用的一个小技巧
在调试代码的阶段,保留#define DEBUG这一行,后面#if defined(DEBUG)部分的代码就可以起作用,打印出一些有助于调试的信息。
等到出release版的时候,就可以把#define DEBUG这一行删掉,或者改成#undef DEBUG,后面那段代码就不会被编译,也就不会打印call times这些东西了
- 关于c语言#define debug
- 关于C语言宏定义#define的心得
- C语言 关于#define 与const 一点心得
- 关于C语言define定义常量的疑惑
- 关于C语言define宏定义字符串常量
- C语言中 关于const和#define的区别心得
- 关于C语言宏定义define的用法探究
- C语言 #define
- C语言#define用法
- C语言 #define 举例
- C语言define之#,##
- C语言 #define用法
- C语言之define
- C语言Define
- C语言当中的#ifdef DEBUG, #define ,#else,#endif等的意义
- 关于C语言中Debug Assertion Failed解决方法
- #define DEBUG
- C语言I-声明#define
- STL经典用例-精简表达式一句话用例
- raw文件系统如何改回ntfs文件系统
- lua单元测试
- struts2学习(5)struts2中的参数传递
- java 一对多
- 关于c语言#define debug
- 最佳编程文本编辑器
- 为什么我就找不到图片中的句柄呢?
- UNIX常用命令
- "_OBJC_CLASS_$_MFMailComposeViewController", referenced from:
- Android AppWidget组件
- finally 不会执行的情况
- Jsp/Servlet 读书笔记(三) -- ServletConfig和ServletContext
- Android触摸屏手势识别