什么是不能够在GCC划分数的原因 [英] What is the cause of not being able to divide numbers in GCC
问题描述
我有一个非常奇怪的情况。每次我尝试编译我的胳膊项目(LPC2378,codesourcery臂无 - 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'
违规的code是这样的:
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&安培; LC选项LD。我已经解决了,仍然错误仍存在。
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.
推荐答案
CPU的ARM系列不具备原生的整数除法指令。这样,除法需要由一个库功能来实现。 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屋!