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

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

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

问题描述:

 

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

zencart迁移需要修改的地方

移植zencart,搬迁zencart:1.复制文件到新的服务器2.复制数据库3.修改配置文件    1)/includes/configure.php       //修改域名('HTTP_SERVER',&nb...

USB转串口 漏电给MCU,如何处理

USB转串口 漏电给MCU,如何处理

参考资料: http://bbs.21ic.com/icview-331251-1-1.html http://bbs.21ic.com/icview-1262058-1-1.html https://zhidao.baidu.com/question/1446506599856343620.htm...

金蝶K3系统单据对应ICTemplate表单ID信息

SELECT FID,FCaption FROM ICTemplate where FFieldName = 'FBillCaption' FID    FCaption A01    外购入库单 A02  &n...

静电实验平台的搭建及要求

静电实验平台的搭建及要求

Test setup 1、Cables: 2m, with 470KΩ * 2 ---EUT and Metal HCP (Horizontal Coupling Plate); ---HCP and Metal Plate connected to the ground 2、Insu...

AutoCAD转Altium

以前写过一篇文章,讲述了AutoCAD如何转Protel99SE [AutoCAD转Protel99SE及丢线问题解决] 现在公司不允许用Protel99SE了(因版权问题),买了正版的Altium。因此,要将AutoCAD转Altium,其实是可以用上面的办法的,那个办法依旧有效。 还有一个...

object-c 函数前面加号和减号 +和-的区别

简单来说就是: 加号 是可以通过类名直接调用这个方法; 减号则要实例化逸个对象,然后通过实例化的对象来调用该方法!! 使用的时候请注意。...

发表评论

访客

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