2021-10-09

2 篇文章 0 订阅
1 篇文章 0 订阅

如何快速验证宏定义是否生效

1.前言
我们在使用宏控制代码模块式,不知道宏控制有没有生效,整体编译验证又很费时间,故在此提出一种便捷方法。
2.正文
可以使用#error插入代码块进行编译测试,对特定目录进行编译--------make 目录名_build

Z:\tmp\RTL3-4-14b\users\rc\Makefile
ifneq ($(CONFIG_APP_CHANGE_FACTORY_SETTINGS),y)
CFLAGS += -DCONFIG_CHANGE_FACTORY_SETTINGS
endif
Z:\tmp\RTL3-4-14b\users\rc\reload.c
#ifdef CONFIG_CHANGE_FACTORY_SETTINGS
#error 11111111111
			else if (i==3)
			{
				printf("Going to Reload ChangeFactorySettingsDefault\n");
				system("flash changefactorysettings");
				system("reboot");
			}
#else
#error 22222222222222222222
#endif//CONFIG_CHANGE_FACTORY_SETTINGS
/work/shuzhi/tmp/RTL3-4-14b/users
[ ! -d "rc" ] || make -C rc || exit $?
make[2]: Entering directory `/work/shuzhi/tmp/RTL3-4-14b/users/rc'
msdk-linux-gcc -Os   -DCONFIG_RTL_819X -DCONFIG_RTL_8197F -DCOMNECT_PRODUCT_NuCom -DCOMNECT_PRODUCT=\"NuCom\"    -c -o reload.o reload.c
reload.c: In function 'main':
reload.c:1403:2: error: #error 22222222222222222222
 #error 22222222222222222222
  ^
reload.c:1478:10: warning: passing argument 1 of 'chk_wlanSch_ksRule' from incompatible pointer type [enabled by default]
          chk_wlanSch_ksRule(&ks[i],i);      
          ^
reload.c:745:6: note: expected 'struct ps_info *' but argument is of type 'struct ps_info (*)[10]'
 void chk_wlanSch_ksRule(struct ps_info *ks, int index)
      ^
reload.c:1489:10: warning: passing argument 1 of 'chk_wlanSch_ksRule' from incompatible pointer type [enabled by default]
          chk_wlanSch_ksRule(&ks[i],i);
          ^
reload.c:745:6: note: expected 'struct ps_info *' but argument is of type 'struct ps_info (*)[10]'
 void chk_wlanSch_ksRule(struct ps_info *ks, int index)
      ^
reload.c:1515:10: warning: passing argument 1 of 'chk_wlanSch_ksRule' from incompatible pointer type [enabled by default]
          chk_wlanSch_ksRule(&ks[i],i);
          ^
reload.c:745:6: note: expected 'struct ps_info *' but argument is of type 'struct ps_info (*)[10]'
 void chk_wlanSch_ksRule(struct ps_info *ks, int index)
      ^
reload.c:1526:10: warning: passing argument 1 of 'chk_wlanSch_ksRule' from incompatible pointer type [enabled by default]
          chk_wlanSch_ksRule(&ks[i],i);
          ^
reload.c:745:6: note: expected 'struct ps_info *' but argument is of type 'struct ps_info (*)[10]'
 void chk_wlanSch_ksRule(struct ps_info *ks, int index)
      ^
reload.c:1558:10: warning: passing argument 1 of 'chk_wlanSch_ksRule' from incompatible pointer type [enabled by default]
          chk_wlanSch_ksRule(&ks[i],i);
          ^
reload.c:745:6: note: expected 'struct ps_info *' but argument is of type 'struct ps_info (*)[10]'
 void chk_wlanSch_ksRule(struct ps_info *ks, int index)
      ^
reload.c:1569:10: warning: passing argument 1 of 'chk_wlanSch_ksRule' from incompatible pointer type [enabled by default]
          chk_wlanSch_ksRule(&ks[i],i);
          ^
reload.c:745:6: note: expected 'struct ps_info *' but argument is of type 'struct ps_info (*)[10]'
 void chk_wlanSch_ksRule(struct ps_info *ks, int index)
      ^
make[2]: *** [reload.o] Error 1
make[2]: Leaving directory `/work/shuzhi/tmp/RTL3-4-14b/users/rc'
make[1]: *** [rc] Error 2
make[1]: Leaving directory `/work/shuzhi/tmp/RTL3-4-14b/users'
make: *** [rc_build] Error 2
shuzhi@software-server:~/tmp/RTL3-4-14b$ 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值