sin()函数的函数原型在哪里,为何 cmath 中没有呢?

lzxlzx777 2009-09-08 04:31:03
sin()函数的函数原型在哪里,为何 cmath 中没有呢?
以下是 cmath 的所有内容,我找不到 sin()函数原型呀,定义估计看不到,因为封装到库函数中了。但是函数原型在头文件中应该有吧,但是为何找不到呢?如何可以找到呢?

// cmath standard header

#if _MSC_VER > 1000
#pragma once
#endif

#ifndef _CMATH_
#define _CMATH_
#ifdef _STD_USING
#undef _STD_USING
#include <math.h>
#define _STD_USING
#else
#include <math.h>
#endif /* _STD_USING */
#endif /* _CMATH_ */

/*
* Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
*/
...全文
467 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
htzyhtzy 2009-09-08
  • 打赏
  • 举报
回复
很多C++头文件都是这样的
htzyhtzy 2009-09-08
  • 打赏
  • 举报
回复
[Quote=引用楼主 lzxlzx777 的回复:]
sin()函数的函数原型在哪里,为何 cmath 中没有呢?
以下是 cmath 的所有内容,我找不到 sin()函数原型呀,定义估计看不到,因为封装到库函数中了。但是函数原型在头文件中应该有吧,但是为何找不到呢?如何可以找到呢?

// cmath standard header

#if    _MSC_VER > 1000
#pragma once
#endif

#ifndef _CMATH_
#define _CMATH_
#ifdef _STD_USING
#undef _STD_USING
#include <math.h>
#define _STD_USING
#else
#include <math.h>
#endif /* _STD_USING */
#endif /* _CMATH_ */

/*
* Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
*/

[/Quote]

这句啊,头文件里包含另一个头文件,很多C++头文件 <cstdio>,<cstring>
#include <math.h>
whg01 2009-09-08
  • 打赏
  • 举报
回复
2楼正解。
baihacker 2009-09-08
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lzxlzx777 的回复:]
      double  __cdecl log(_In_ double _X);
        double  __cdecl log10(_In_ double _X);
        double  __cdecl pow(_In_ double _X, _In_ double _Y);
        double  __cdecl sin(_In_ double _X);
        double  __cdecl sinh(_In_ double _X);
        double  __cdecl tan(_In_ double _X);
        double  __cdecl tanh(_In_ double _X);
        double  __cdecl sqrt(_In_ double _X);

以上加红的地方,是函数原型吗?
定义肯定看不到,但是原型应该能看到吧。因为我要声明它呀。
[/Quote]
是的,这就是原型。
lzxlzx777 2009-09-08
  • 打赏
  • 举报
回复
double __cdecl log(_In_ double _X);
double __cdecl log10(_In_ double _X);
double __cdecl pow(_In_ double _X, _In_ double _Y);
double __cdecl sin(_In_ double _X);
double __cdecl sinh(_In_ double _X);
double __cdecl tan(_In_ double _X);
double __cdecl tanh(_In_ double _X);
double __cdecl sqrt(_In_ double _X);

以上加红的地方,是函数原型吗?
定义肯定看不到,但是原型应该能看到吧。因为我要声明它呀。
TTOJJ 2009-09-08
  • 打赏
  • 举报
回复
好久没碰tc了~~帮顶,是不是在lib里???也可以不在头文件里的
mstlq 2009-09-08
  • 打赏
  • 举报
回复
std::sin()……

或者
using namespace std;
sin();

或者
using std::sin;
sin();
baihacker 2009-09-08
  • 打赏
  • 举报
回复
要注意,里面还包含了一个math.h

/***
*math.h - definitions and declarations for math library
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file contains constant definitions and external subroutine
* declarations for the math subroutine library.
* [ANSI/System V]
*
* [Public]
*
****/

#ifndef _INC_MATH
#define _INC_MATH

#include <crtdefs.h>

#ifdef _MSC_VER
/*
* Currently, all MS C compilers for Win32 platforms default to 8 byte
* alignment.
*/
#pragma pack(push,_CRT_PACKING)
#endif /* _MSC_VER */

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#ifndef __assembler

/* Definition of _exception struct - this struct is passed to the matherr
* routine when a floating point exception is detected
*/

#ifndef _EXCEPTION_DEFINED
struct _exception {
int type; /* exception type - see below */
char *name; /* name of function where error occured */
double arg1; /* first argument to function */
double arg2; /* second argument (if any) to function */
double retval; /* value to be returned by function */
} ;

#define _EXCEPTION_DEFINED
#endif /* _EXCEPTION_DEFINED */


/* Definition of a _complex struct to be used by those who use cabs and
* want type checking on their argument
*/

#ifndef _COMPLEX_DEFINED
struct _complex {
double x,y; /* real and imaginary parts */
} ;

#if !__STDC__ && !defined (__cplusplus)
/* Non-ANSI name for compatibility */
#define complex _complex
#endif /* !__STDC__ && !defined (__cplusplus) */

#define _COMPLEX_DEFINED
#endif /* _COMPLEX_DEFINED */
#endif /* __assembler */


/* Constant definitions for the exception type passed in the _exception struct
*/

#define _DOMAIN 1 /* argument domain error */
#define _SING 2 /* argument singularity */
#define _OVERFLOW 3 /* overflow range error */
#define _UNDERFLOW 4 /* underflow range error */
#define _TLOSS 5 /* total loss of precision */
#define _PLOSS 6 /* partial loss of precision */

#define EDOM 33
#define ERANGE 34


/* Definitions of _HUGE and HUGE_VAL - respectively the XENIX and ANSI names
* for a value returned in case of error by a number of the floating point
* math routines
*/
#ifndef __assembler
#if !defined (_M_CEE_PURE)
_CRTIMP extern double _HUGE;
#else /* !defined (_M_CEE_PURE) */
const double _HUGE = System::Double::PositiveInfinity;
#endif /* !defined (_M_CEE_PURE) */
#endif /* __assembler */

#define HUGE_VAL _HUGE

/* Function prototypes */

#if !defined (__assembler)
#ifndef _CRT_ABS_DEFINED
#define _CRT_ABS_DEFINED
int __cdecl abs(_In_ int _X);
long __cdecl labs(_In_ long _X);
#endif /* _CRT_ABS_DEFINED */

double __cdecl acos(_In_ double _X);
double __cdecl asin(_In_ double _X);
double __cdecl atan(_In_ double _X);
double __cdecl atan2(_In_ double _Y, _In_ double _X);
#ifndef _SIGN_DEFINED
_Check_return_ _CRTIMP double __cdecl _copysign (_In_ double _Number, _In_ double _Sign);
_Check_return_ _CRTIMP double __cdecl _chgsign (_In_ double _X);
#define _SIGN_DEFINED
#endif /* _SIGN_DEFINED */
double __cdecl cos(_In_ double _X);
double __cdecl cosh(_In_ double _X);
double __cdecl exp(_In_ double _X);
_CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double _X);
double __cdecl fmod(_In_ double _X, _In_ double _Y);
double __cdecl log(_In_ double _X);
double __cdecl log10(_In_ double _X);
double __cdecl pow(_In_ double _X, _In_ double _Y);
double __cdecl sin(_In_ double _X);
double __cdecl sinh(_In_ double _X);
double __cdecl tan(_In_ double _X);
double __cdecl tanh(_In_ double _X);
double __cdecl sqrt(_In_ double _X);
#ifndef _CRT_ATOF_DEFINED
#define _CRT_ATOF_DEFINED
_Check_return_ _CRTIMP double __cdecl atof(_In_z_ const char *_String);
_Check_return_ _CRTIMP double __cdecl _atof_l(_In_z_ const char *_String, _In_opt_ _locale_t _Locale);
#endif /* _CRT_ATOF_DEFINED */

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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