math.h文件中关于 #define _ARMABI __declspec(__nothrow)的问题

elimentli 2016-07-14 04:43:53
在math.h 中有如下定义

#ifndef __math_h
#define __math_h
//...
#define _ARMABI __declspec(__nothrow)
#define _ARMABI_PURE __declspec(__nothrow) __attribute__((const))
//...
/* C99 float versions of functions. math.h has always reserved these
identifiers for this purpose (7.13.4). */
extern _ARMABI float sinf(float /*x*/);
extern _ARMABI float cosf(float /*x*/);
extern _ARMABI float (float /*x*/);


请问 这个__declspec(__nothrow) 是什么意思? 没有见过这种格式
还有下面的sinf, cosf,tanf 看起来像是三角函数,这个是函数体吗?其中的下划线有什么特殊含义吗?

inline float atan(float __x) { return atanf(__x); }

...全文
864 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
elimentli 2016-07-14
  • 打赏
  • 举报
回复
引用 3 楼 cftxlin 的回复:
后面的怎么不是函数,是函数的,是函数声明,至于函数体,是库里面的,我们不用管,__x是参数名,参数可以以下划线开头不是
请问 这些函数体是不是对外不可见的? 还有下面在这个文件中使用了这个函数

void LPF2pSetCutoffFreq_1(float sample_freq, float cutoff_freq)
{
		float fr =0;  
    float ohm =0;
    float c =0;
	
		fr= sample_freq/cutoff_freq;
//在这里调用
		ohm=tanf(M_PI_F/fr);
		//......
}
选中这个函数以后,右键选择Go to definition of 'tanf',IDE提示 undefined Definiton我试了试 右键选择Go to Refernece to 'tanf',然后就跳转到了这个math.h 文件,我之前想查看引用的某个函数的定义,都是选择Go to definition of 'tanf',就可以跳转到函数的具体实现部分,这个为什么这么特别?(顺利编译没有报错)
小灸舞 版主 2016-07-14
  • 打赏
  • 举报
回复
nothrow:
格式:return-type __declspec(nothrow) [call-convention] function-name ([argument-list])
可用于函数声明。告诉编译器被声明的函数以及函数内部调用的其它函数都不会抛出异常。
  • 打赏
  • 举报
回复
后面的怎么不是函数,是函数的,是函数声明,至于函数体,是库里面的,我们不用管,__x是参数名,参数可以以下划线开头不是
  • 打赏
  • 举报
回复
__declspec(__nothrow) 函数修饰符,告诉编译器,这个函数不会抛出异常
elimentli 2016-07-14
  • 打赏
  • 举报
回复
这个是math.h 中的部分内容

#ifndef __USE_C99_MATH
  #if defined(__USE_C99_ALL) || (defined(__STDC_VERSION__) && 199901L <= __STDC_VERSION__)
    #define __USE_C99_MATH 1
  #endif
#endif

#define _ARMABI __declspec(__nothrow)
#ifdef __TARGET_ARCH_AARCH64
# define _ARMABI_SOFTFP __declspec(__nothrow)
#else
# define _ARMABI_SOFTFP __declspec(__nothrow) __attribute__((__pcs__("aapcs")))
# define __HAVE_LONGDOUBLE 1
#endif
#define _ARMABI_PURE __declspec(__nothrow) __attribute__((const))
#ifdef __FP_FENV_EXCEPTIONS
# define _ARMABI_FPEXCEPT _ARMABI
#else
# define _ARMABI_FPEXCEPT _ARMABI __attribute__((const))
#endif

/* C99 float versions of functions.  math.h has always reserved these
   identifiers for this purpose (7.13.4). */
extern _ARMABI_PURE float _fabsf(float); /* old ARM name */
_ARMABI_INLINE _ARMABI_PURE float fabsf(float __f) { return _fabsf(__f); }
extern _ARMABI float sinf(float /*x*/);
extern _ARMABI float cosf(float /*x*/);
extern _ARMABI float tanf(float /*x*/);
extern _ARMABI float acosf(float /*x*/);
extern _ARMABI float asinf(float /*x*/);
extern _ARMABI float atanf(float /*x*/);
extern _ARMABI float atan2f(float /*y*/, float /*x*/);
extern _ARMABI float sinhf(float /*x*/);
extern _ARMABI float coshf(float /*x*/);
extern _ARMABI float tanhf(float /*x*/);
extern _ARMABI float expf(float /*x*/);
extern _ARMABI float logf(float /*x*/);
extern _ARMABI float log10f(float /*x*/);
extern _ARMABI float powf(float /*x*/, float /*y*/);
extern _ARMABI float sqrtf(float /*x*/);
extern _ARMABI float ldexpf(float /*x*/, int /*exp*/);
extern _ARMABI float frexpf(float /*value*/, int * /*exp*/) __attribute__((__nonnull__(2)));
extern _ARMABI_PURE float ceilf(float /*x*/);
extern _ARMABI_PURE float floorf(float /*x*/);
extern _ARMABI float fmodf(float /*x*/, float /*y*/);
extern _ARMABI float modff(float /*value*/, float * /*iptr*/) __attribute__((__nonnull__(2)));


#ifdef __cplusplus
  extern "C++" {
    inline float abs(float __x)   { return fabsf(__x); }
    inline float acos(float __x)  { return acosf(__x); }
    inline float asin(float __x)  { return asinf(__x); }
    inline float atan(float __x)  { return atanf(__x); }
    inline float atan2(float __y, float __x)    { return atan2f(__y,__x); }
    inline float ceil(float __x)  { return ceilf(__x); }
    inline float cos(float __x)   { return cosf(__x); }
    inline float cosh(float __x)  { return coshf(__x); }
    inline float exp(float __x)   { return expf(__x); }
    inline float fabs(float __x)  { return fabsf(__x); }
    inline float floor(float __x) { return floorf(__x); }
    inline float fmod(float __x, float __y)     { return fmodf(__x, __y); }
    float frexp(float __x, int* __exp) __attribute__((__nonnull__(2)));
    inline float frexp(float __x, int* __exp)   { return frexpf(__x, __exp); }
    inline float ldexp(float __x, int __exp)    { return ldexpf(__x, __exp);}
    inline float log(float __x)   { return logf(__x); }
    inline float log10(float __x) { return log10f(__x); }
    float modf(float __x, float* __iptr) __attribute__((__nonnull__(2)));
    inline float modf(float __x, float* __iptr) { return modff(__x, __iptr); }
    inline float pow(float __x, float __y)      { return powf(__x,__y); }
    inline float pow(float __x, int __y)     { return powf(__x, (float)__y); }
    inline float sin(float __x)   { return sinf(__x); }
    inline float sinh(float __x)  { return sinhf(__x); }
    inline float sqrt(float __x)  { return sqrtf(__x); }
    inline float _sqrt(float __x) { return _sqrtf(__x); }
    inline float tan(float __x)   { return tanf(__x); }
    inline float tanh(float __x)  { return tanhf(__x); }

    inline double abs(double __x) { return fabs(__x); }
    inline double pow(double __x, int __y)
                { return pow(__x, (double) __y); }

70,037

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧