orlp
orlp

Reputation: 117711

C naming conventions for numeric functions?

Say I have this function:

int epic(int);

I know of these naming conventions, are these right? Do other very common ones exist?

              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);

Upvotes: 3

Views: 172

Answers (2)

janneb
janneb

Reputation: 37208

Sometimes, if the return type differs from the argument type(s), a prefix is used to indicate this. Consider for example the following (from 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);

Upvotes: 1

ApprenticeHacker
ApprenticeHacker

Reputation: 22021

Well you pretty much summed up most of them. A few you forgot are

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

In some embedded systems like 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); 

Upvotes: 0

Related Questions