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

相關文章
相關標籤/搜索