GCC中无法进行数字除法的原因是什么 [英] What is the cause of not being able to divide numbers in 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'
违规代码如下所示:
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屋!