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

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

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

问题描述:

 

将函数名存储在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 解决” 的相关文章

ReportViewer(RDLC报表)打印很多空白页

ReportViewer(RDLC报表)打印很多空白页

问题: RDLC报表打印的时候,会多出空白页。 一页有内容,一页空白。然后有内容,然后继续空白。交替出现空白。 原因: 报表的宽度+左边距+右边距 > 纸张宽度 参考资料: https://blog.csdn.net/u012293369/article/details/78885091 解决...

C# WinForm带参数运行 如:1.exe -a

建立好了项目文件后,需要修改的地方有两点! 1:修改 Program 类中的Main方法 加上入口点,并且将参数传递到Form1窗体 2:修改 Form1窗体的构造函数,允许传参。 下面是代码: Program.cs代码如下: namespace ParameterApp {   ...

SVN取消版本控制

SVN取消版本控制

想要取消某个文件夹的SVN版本控制 想要取消它,没有直接显而易见的办法。TortoiseSVN里自带了工具,只不过方法比较诡异。 右键选中目录,TortoiseSVN->导出 导出目录和现有的目录必须一致。 然后,就会提示你取消版本控制。选“移除版本控制”即可。...

怎样清空SQL SERVER数据库,清空后让表的ID自增列从1开始??

1、truncate table 表名2、dbcc checkident(表名,RESEED,0)...

Android x86 4.4 RC2卡在跳过Wifi后面一步

Android x86 4.4 RC2卡在跳过Wifi后面一步

问题:Android x86 4.4 RC2卡在跳过Wifi后面一步,没法跳过,一直死循环。 无论怎么改都在这步了, 返回了也不知道从哪可以跳过。   解决办法: 一、在语言选择界面用鼠标在 左上-右上-右下-左下 四个角各点一遍 这个方法不知道是谁试出来的,这么扯蛋的办法都能想到。 二...

Keil MDK 查看局部变量提示<not in scope>

Keil MDK 查看局部变量提示

现象: 在进行STM32开发的时候出现了,调试代码,添加变量Watch时,显示not in scope。 处理方式: 因为代码开了优化的处理,把优化改到Level0,就可以解决问题。...

发表评论

访客

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