2012-03-21 77 views
3

說我有這個功能:數字函數的C命名約定?

int epic(int); 

我知道這些命名約定的,這些都是正確的?還有其他非常常見的嗎?

   long epicl (long); 
     long long epicll (long long); 
     unsigned int epicu (unsigned int); 
    unsigned long epicul (unsigned long); 
unsigned long long epicull (unsigned long long); 
      double fepic (double); 
      float fepicf (float); 
+1

'長雙fepicl(長雙);',也許(JK)'uint64_t中epicu64(uint64_t中);' – pmg 2012-03-21 11:18:38

+2

@close選民:沒有建設性? _我們希望答案通常涉及事實,參考或__specific專業知識__._我真的想知道這一點,因爲我正在寫一些數字圖書館,併爲我的一般知識。 – orlp 2012-03-21 11:22:31

+0

如果沒有歧義,標準的數學函數就不會帶領'f ...' – Christoph 2012-03-21 11:31:41

回答

1

有時候,如果返回類型從參數類型不同,前綴是用來表明這一點。例如,考慮以下(從C99):


double round(double x); 
float roundf(float x); 
long double roundl(long double x); 

long int lround(double x); 
long int lroundf(float x); 
long int lroundl(long double x); 

long long int llround(double x); 
long long int llroundf(float x); 
long long int llroundl(long double x); 
0

那麼你幾乎總結了他們大多數。你忘了有幾個是

long double fepicl(long double); /* thanks @pmg */ 
double epich(double); /* if epic is a hyperbolic function */ 

在像ARM某些嵌入式系統:

/* disclaimer, once saw them in an unofficial ARM SDK, 
* not sure if these conventions are standard */ 
u8 epic_8(u8); 
u16 epic_16(u16);