问题十一:用条件编译(#if…#endif)避免 main函数中测试代码在测试完成后就删除
来源:互联网 发布:java写hello world 编辑:程序博客网 时间:2024/06/06 17:42
#define testNumber 3
/*
1: output the first image
2: test "int &ri,int& ri,int*&pri"
3: output the first image by using vector.
*/
#if testNumber == 1 /*1: output the first image*/
//完整的测试代码1
#elif testNumber == 2 /*2: test "int &ri,int& ri,int*&pri"*/
//完整的测试代码2
#elif testNumber == 3 /*3: output the first image by using vector.*/
//完整的测试代码3
#endif // testNumber
可以通过修改宏定义中testNumber的值来控制编译的代码块,也就是控制测试模块。
想测试哪一块,就将testNumber修改成对应的值即可;
想添加一个新的测试块,在添加一个“#elif testNumber == …”即可。
4 0
- 问题十一:用条件编译(#if…#endif)避免 main函数中测试代码在测试完成后就删除
- 条件编译(#ifdef #else #endif #if)
- 条件编译(#ifdef #else #endif #if)
- #if和#ifdef使用问题&预处理命令之条件编译(#ifdef,#else,#endif,#if等)
- 函数单独编译与函数在main函数中调用编译后生成汇编代码对比
- java中if判断条件语句测试代码总结
- C语言中条件编译命令(#if #else #endif)(
- C语言中条件编译命令(#if #else #endif)
- C语言中条件编译命令(#if #else #endif)
- C语言中条件编译命令(#if #else #endif)
- 预处理命令之条件编译(#ifdef,#else,#endif,#if)
- #if #elif #endif 的使用--------条件编译(conditional compilation)
- 条件编译(#ifdef,#else,#endif,#if等)
- 条件编译 #if, #elif, #else, #endif
- 条件编译 #if #endif #ifdef等
- 条件判断语句(if...else)与条件编译(#if .... #else ... #endif)
- 解决/**/嵌套问题---条件编译:#if 0 statement #endif 帅帅哒洋办法
- 第五周上机任务--任务二--在main()函数中自行定义对象,调用各成员函数,完成基本的测试
- C/C++ 刷题小知识点
- mac book 配置
- Linux文本文件与WIN文本文件换行格式转换命令
- What is Angular 2? High level overview, feature and fundamentals.
- 什么是中间件
- 问题十一:用条件编译(#if…#endif)避免 main函数中测试代码在测试完成后就删除
- 数据结构实验之栈四:括号匹配
- C++ 语法实验室之 static 关键字
- 区间覆盖问题
- zeppelin mysql可视化之旅
- 数据结构实验之栈八:栈的基本操作
- 1123. Is It a Complete AVL Tree (30)
- 什么是WebLogic
- angular.js的$digest循环