数字函数的C命名约定?
假设我有这个功能:数字函数的C命名约定?,c,naming-conventions,C,Naming Conventions,假设我有这个功能: 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 l
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);
你几乎总结了其中的大部分。有几个你忘记了
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);
有时,如果返回类型与参数类型不同,则会使用前缀来表示这一点。考虑下面的例子(从C99):
长双fepicl(长双)代码>和可能(JK)uint64(uint64)代码>@close投票人:不是建设性的?我们希望答案通常包括事实、参考资料或特定专业知识。我真的很想知道这一点,因为我正在编写一些数字库,而且是为了我的常识。标准数学函数没有前导f…
如果没有歧义,如果你有一个C11编译器,你就有泛型来解决这个命名混乱。见例。
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);