libpam:shadow.h:error: expected declaration specifiers before '__THROW'

本文详细介绍了在使用Android gcc编译时遇到的cdefs.h版本问题,导致__THROW未定义错误的解决方法。通过从GNU gcc cdefs.h复制相关定义,成功解决了该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

When I'm makeing libpam, it claims that there's no shadow.h. Then I found a shadow.h.

But another issue shows up: error: expected declaration specifiers before '__THROW'.

This is because Android gcc is using cdefs.h of the following version:

/*$NetBSD: cdefs.h,v 1.58 2004/12/11 05:59:00 christos Exp $*/

And there's no '__THROW' definition in it.

So I copy '__THROW' definition from the GNU gcc cdefs.h .

Here's the definition :

#ifdef __GNUC__

/* 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__))
# define __NTH(fct)__attribute__ ((__nothrow__)) fct
# else
# if defined __cplusplus && __GNUC_PREREQ__ (2,8)
# define __THROWthrow ()
# define __NTH(fct)fct throw ()
# else
# define __THROW
# define __NTH(fct)fct
# endif
# endif

#else/* Not GCC. */

# define __inline/* No inline functions. */

# define __THROW
# define __NTH(fct)fct

# define __constconst
# define __signedsigned
# define __volatilevolatile

#endif/* GCC. */

it seems to be fine now.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值