最近调试TA编译,碰到一个问题,总是提示:
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__THROW’
1,首先在网上找到了各路大神的解决方案,基本上确认是C++/C的兼容问题,但是提的
解决方案是使用g++替换gcc。
2. 但在具体我们碰到的问题中,并不是这样。搞了好久,一直没有解决,后面在代码中
找了下__THROW和__BEGIN_DECLS,在cdefs.h中,有2个,其中一个内容是没有的(原始
自带的),另外一个是gun下的有;问题找到。
3.经过了近3天的时间,中间尝试了好多方法,都没成功;最后发现,还是直接解决错误,
比较快捷....., 当然也是基于总的方向上是正确的
../mootee-ta_arm32/libc/include/sys/cdefs.h
/* GCC can always grok prototypes. For C++ programs we add throw()
to help it optimize the function calls. But this works only with
gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
as non-throwing using a function attribute since programs can use
the -fexceptions options for C code as well. */
# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
# define __THROW __attribute__ ((__nothrow__ __LEAF))
# define __THROWNL __attribute__ ((__nothrow__))
# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
# else
# if defined __cplusplus && __GNUC_PREREQ (2,8)
# define __THROW throw ()
# define __THROWNL throw ()
# define __NTH(fct) __LEAF_ATTR fct throw ()
# else
# define __THROW
# define __THROWNL
# define __NTH(fct) fct
# endif
# endif
#else /* Not GCC. */
# define __inline /* No inline functions. */
# define __THROW
# define __THROWNL
# define __NTH(fct) fct
#endif /* GCC. */