内联函数(inline)相关的编译错误
- 1.重定义(redefinition)
- 2.receive.c:562:7: warning: 'expect_at_least' is static but used in inline function 'get_gap' which is not static
编译第三开源包的时遇到了一些问题,在海思提供的工具链(arm-gcc49-linux-gnueabihf-4.9.4)没遇到错误,
换用mtk 的工具链(arm-linux-gnueabihf-7.2.1)编译时,遇到如下内联函数相关错误
1.重定义(redefinition)
lircd
mkfs.ubifs/hashtable/hashtable_itr.c:42:1: error: redefinition of ‘hashtable_iterator_key’
hashtable_iterator_key(struct hashtable_itr *i)
^~~~~~~~~~~~~~~~~~~~~~
In file included from mkfs.ubifs/hashtable/hashtable_itr.c:5:0:
mkfs.ubifs/hashtable/hashtable_itr.h:32:1: note: previous definition of ‘hashtable_iterator_key’ was here
hashtable_iterator_key(struct hashtable_itr *i)
^~~~~~~~~~~~~~~~~~~~~~
查看代码发现
hashtable_itr.c 中
void *
hashtable_iterator_key(struct hashtable_itr *i)
{ return i->e->k; }
hashtable_itr.h 中
extern inline void *
hashtable_iterator_key(struct hashtable_itr *i)
{
return i->e->k;
}
解决方法:
在CFLAGS 中加入 -fgnu89-inline
export CFLAGS=" -fgnu89-inline "
2.receive.c:562:7: warning: ‘expect_at_least’ is static but used in inline function ‘get_gap’ which is not static
mtd-utils
后面链接报错
receive.c:(.text+0x21fe): undefined reference to get_gap' receive.c:(.text+0x2210): undefined reference to
get_gap’
解决方法:(同上)
在CFLAGS 中加入 -fgnu89-inline
export CFLAGS=" -fgnu89-inline "
遇到类似的问题可以参考