error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__THROW’z

最近调试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.  */

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值