FUNCS.H中的函数声明

/*
**************************************************************************
                                                                  
FUNCS.H -- Function Prototypes for EPANET Program                      
                                                                  
VERSION:    2.00
DATE:       5/8/00
            9/25/00
            10/25/00
            12/29/00
            3/1/01
            2/14/08    (2.00.12)
AUTHOR:     L. Rossman
            US EPA - NRMRL
                                                                               
**************************************************************************
*/node

/*****************************************************************/
/*   Most float arguments have been changed to double - 7/3/07   */
/*****************************************************************/app

/* ------- EPANET.C --------------------*/
/*
**  NOTE: The exportable functions that can be called
**        via the DLL are prototyped in TOOLKIT.H.
*/
void    initpointers(void);               /* Initializes pointers       */
int     allocdata(void);                  /* Allocates memory           */
void    freeTmplist(STmplist *);          /* Frees items in linked list */
void    freeFloatlist(SFloatlist *);      /* Frees list of floats       */
void    freedata(void);                   /* Frees allocated memory     */
int     openfiles(char *,char *,char *);  /* Opens input & report files */
int     openhydfile(void);                /* Opens hydraulics file      */
int     openoutfile(void);                /* Opens binary output file   */
int     strcomp(char *, char *);          /* Compares two strings       */
char*   getTmpName(char* fname);          /* Gets temporary file name   */     //(2.00.12 - LR)
double  interp(int, double *,             /* Interpolates a data curve  */
               double *, double);
int     findnode(char *);                 /* Finds node's index from ID */
int     findlink(char *);                 /* Finds link's index from ID */
char*   geterrmsg(int);                   /* Gets text of error message */
void    errmsg(int);                      /* Reports program error      */
void    writecon(char *);                 /* Writes text to console     */
void    writewin(char *);                 /* Passes text to calling app */函数

.....spa

 

------------------------------------------------prototype

在主调函数中调用某函数以前应对该被调函数进行说明(声明),这与使用变量以前要先进行变量说明是同样的。在主调函数中对被调函数做说明的目的是使编译系统知道被调函数返回值的类型,以便在主调函数中按此种类型对返回值做相应的处理。
其通常形式为:
        类型说明符 被调函数名(类型 形参,类型 形参 …);  
或为:
        类型说明符 被调函数名(类型,类型 …);   //明显,EPANET中的函数声明的格式都是属于这类.
括号内给出了形参的类型和形参名,或只给出形参类型。这便于编译系统进行检错,以防止可能出现的错误。
例 main 函数中对 max 函数的说明为:
int max(int a,int b);
或写为:
        int max(int,int);
C语言中又规定在如下几种状况时能够省去主调函数中对被调函数的函数说明。
1)  若是被调函数的返回值是整型或字符型时,能够不对被调函数做说明,而直接调用。这时系统将自动对被调函数返回值按整型处理。get

2)  当被调函数的函数定义出如今主调函数以前时,在主调函数中也能够不对被调函数再做说明而直接调用input

3)  如在全部函数定义以前,在函数外预先说明了各个函数的类型,则在之后的各主调函数中,可再也不对被调函数做说明。string

4)  对库函数的调用不须要再做说明,但必须把该函数的头文件用 include 命令包含在源文件前部。it

相关文章
相关标签/搜索