GCC中无法除数的原因是什么 [英] What is the cause of not being able to divide numbers in GCC

查看:38
本文介绍了GCC中无法除数的原因是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况很奇怪.每次我尝试编译我的 arm 项目(LPC2378,codesourcery arm-none-eabi-gcc-4.5.1)时,我在链接时都会遇到同样的错误

i'm having a very strange situation. Every time I try to compile my arm project (LPC2378, codesourcery arm-none-eabi-gcc-4.5.1) I am left with the same error whilst linking

/media/data/Projects/arm/uart/main.c:39: undefined reference to `__aeabi_uidiv'
/media/data/Projects/arm/uart/main.c:40: undefined reference to `__aeabi_uidiv'

有问题的代码如下所示:

The offending code looks like this:

U0DLL = ((((PLLCFG & 0x7FFF) + 1) * F_OSC) / ((((PLLCFG & (0xFF << 16)) >> 16) + 1) * ((CCLKCFG & 0xFF) + 1) * 8 * BAUD * 1)) % 256;
U0DLM = ((((PLLCFG & 0x7FFF) + 1) * F_OSC) / ((((PLLCFG & (0xFF << 16)) >> 16) + 1) * ((CCLKCFG & 0xFF) + 1) * 8 * BAUD * 1)) / 256;

我已经四处搜索,这可能是由 AFAICT 引起的,而不是使用 lgcc &LD 的 lc 选项.我已经解决了,但错误仍然存​​在.

I've searched around and what this can be caused by, AFAICT, not using lgcc & lc options for LD. I've resolved that and still the error remains.

完整的项目可以在 在我的 github 存储库中找到.

如果有人可以提供帮助,我们将不胜感激.干杯.

If anybody could help it would be greatly received. Cheers.

推荐答案

ARM 系列 CPU 没有原生整数除法指令.所以,除法需要通过库函数来实现.GCC 知道这一点,并创建对(在您的情况下)__aeabi_uidiv 的引用(对于 unsigned int 部门).

The ARM family of CPUs does not have a native integer division instruction. So, division needs to be implemented by a library function. GCC knows this, and creates a reference to (in your case) __aeabi_uidiv (for unsigned int division).

您需要链接到包含此函数的适当运行时支持库.

You will need to link with an appropriate runtime support library that contains this function.

这篇关于GCC中无法除数的原因是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆