testbed踩坑:因为被测函数设置导致的重定义报错

[复制链接]
 楼主| keer_zu 发表于 2023-1-19 16:50 | 显示全部楼层 |阅读模式
遇到循环怎么处理?比如这种情况:

1861363c904484d219.png

如果设成true,会一直循环下去。
 楼主| keer_zu 发表于 2023-1-19 16:51 | 显示全部楼层
解决的思路还是:宏替换
下面给出一种方法。
 楼主| keer_zu 发表于 2023-1-19 16:52 | 显示全部楼层
下面是这种方法的具体描述:

9641963c904ce2e918.png
 楼主| keer_zu 发表于 2023-1-19 17:05 | 显示全部楼层
pre-include:

  1. /*
  2. * Pre-include code will be placed here
  3. * this code is located at global scope and should consist of
  4. * declarations, preprocessor directives (e.g. #include) or procedures
  5. */
  6. static int loopValue=0;

  7. int stub(void)
  8. {
  9.         if(loopValue)==0) {
  10.                 loopValue=1;
  11.         } else {
  12.                 loopValue=0;
  13.         }

  14.         return loopValue;
  15. }

  16. #define while(expression) while(stub())
 楼主| keer_zu 发表于 2023-1-19 17:06 | 显示全部楼层
post-inclue code:

  1. /*
  2. * Post-include code will be placed here
  3. * this code is located at global scope and should consist of
  4. * declarations, preprocessor directives (e.g. #include) or procedures
  5. */
  6. #undef while(expression)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:qq群:49734243 Email:zukeqiang@gmail.com

1478

主题

12917

帖子

55

粉丝
快速回复 在线客服 返回列表 返回顶部
个人签名:qq群:49734243 Email:zukeqiang@gmail.com

1478

主题

12917

帖子

55

粉丝
快速回复 在线客服 返回列表 返回顶部