当前位置:首页 > 技术心得 > 正文内容

BL51: WARNING L13 (RECURSIVE CALL TO SEGMENT) WITH CONSTANTS 解决

xjtudll8年前 (2018-04-21)技术心得13420

问题描述:

 

将函数名存储在table里,通过函数指针的方式调用函数。

编译提示:

BL51: WARNING L13 (RECURSIVE CALL TO SEGMENT) WITH CONSTANTS

使用环境:

C51 Version 7.00

代码例程(使用Keil官方资料来说明):

文件名是:EXAMPLE1.C

void func1 (unsigned char *msg) {

  ;

}

void func2 (void) {

  unsigned char uc;

  func1("xxxxxxxxxxxxxxx");

}

code void (*func_array[])() = { func2 };

void main( void ) {

  (*func_array[0])();

}

编译的时候就会提示:

*** WARNING 13: RECURSIVE CALL TO SEGMENT

SEGMENT: ?CO?EXAMPLE1

CALLER: ?PR?FUNC2?EXAMPLE1

原因:

In this program example, func2 defines a constant string ("xxx...xxx") which is located in the constant code segment ?CO?EXAMPLE1. The definition:

code void (*func_array[])() = { func2 };

generates a reference between segment ?CO?EXAMPLE1 (where the code table is located) and the executable code segment ?PR?FUNC2?EXAMPLE1. Since func2 also refers to segment ?CO?EXAMPLE1, BL51 assumes that there is a recursive call.

官方的解决办法:

RESOLUTION

To avoid this problem, you must manually remove the reference between func2 and the ?CO?EXAMPLE1 segment. The following overlay directive does that:

bl51 EXAMPLE1.OBJ IX OVERLAY (?CO?EXAMPLE1 ~ FUNC2, MAIN ! FUNC2)

?CO?EXAMPLE1 ~ FUNC2 deletes the implied call reference between func2 and the code constant segment in the example. Then, MAIN ! FUNC2adds a reference between MAIN and FUNC2. This is required because main calls func2 indirectly. Note that automatic overlay analysis does not allow for references made to functions via pointers. References of this type must be manually implemented, as in the example above.

另一个办法:

将code void (*func_array[])() = { func2 }; 放在另一个C文件里,这样就规避了所谓的递归调用了。

 

参考文献:

http://www.keil.com/support/docs/2379.htm

http://blog.csdn.net/avideointerfaces/article/details/32687899

扫描二维码推送至手机访问。

版权声明:本文由鸟的天空发布,如需转载请注明出处。

本文链接:http://xjtudll.cn/Exp/497/

标签: keil
分享给朋友:

“BL51: WARNING L13 (RECURSIVE CALL TO SEGMENT) WITH CONSTANTS 解决” 的相关文章

C语言交换两个数

可能大家都认为交换两个数如此的简单,没必要写,没新意。例如,交换a和b两个数,教科书上一直这样写: temp=b; a=temp; b=a; 确实很简单。但是最近看到一段代码,觉得十分高超,是这样的: a^=b; b^=a; a^=b; 同样也是三句代码,但是却未...

word文档无法打开插入文档里的RAR文件

问题: 办公室的电脑打不开插入word文档插入文档里的RAR文件,但在其他电脑上可以打开。打开时提示:此对象创建于Package中。此应用程序不能用来打开此对象。请确认此应用程序已正确安装,并且未被删除、移动或重命名。 请问该问题如何解决?谢谢! 答案: C:\WINDOWS\system32 目录...

水晶报表字符串字体大小根据字数调整

在实际应用中,可能需要根据字数多少来调整字体的大小。简单介绍一个方法。          选择要设置的字段,右键->设置对象格式->字体->大小,单击右边的x+2进入公式工作室,输入如下代码: if L...

SQL累减语句

https://bbs.csdn.net/topics/70362619 表一 Item Qty A 10 A 12 A 14 B 13 B 60 C 30 C 40 C 10 表二 Item Qty A...

android 停止Handler

mHandler.removeCallbacks(mRunnable); 或者 mHandler.removeMessages(what); mHandler.removeCallbacksAndMessages(null) 参数为null的话,会将所有的Callbacks和Messages全部清除...

BMP2PCB使用教程

BMP2PCB使用教程

BMP2PCB是一款将BMP图片转换成PCB图的工具软件,我们可以用它在Protel99SE中添加汉字或图形。如果要添加文字的话,首先就要将文字转化成图片了。需要注意的是,图片最好是单色位图。可先将BMP转化成单色位图,如图所示。 新版的BMP2PCB不仅仅支持转换成Protel PCB格式,...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。