Page 1 of 1

Talking about naming conventions

Posted: Wed Oct 10, 2012 11:33 am
by Tectu
Hello Folks,

I'd like to hear your opinion about the following: I always declare a struct with a _t suffix in the name, like the following:

Code: Select all

typedef struct cal_t {
    float xm;
    float ym;
    float xn;
    float yn;
} cal_t;


But currently, a few structs in the library, like the Touchpad- and the GDISP driver struct do not have that suffix.
I guess we don't need to argue about having both or not, we should just decide and stick to one.

Personally, I like the _t prefix pretty much, because I think that this reads itself a bit better:

Code: Select all

struct cal_t cal;

than

Code: Select all

struct cal cal;


What do you guys think? What should we choose and why?


~ Tectu

Re: Talking about naming conventions

Posted: Wed Oct 10, 2012 12:58 pm
by Tectu
Over IRC, mobyfab and barthess both told me that they both prefer the _t suffix.


~ Tectu

Re: Talking about naming conventions

Posted: Wed Oct 10, 2012 1:02 pm
by Giovanni
Usually _t is for types in general not structures.

Giovanni

Re: Talking about naming conventions

Posted: Wed Oct 10, 2012 2:17 pm
by Tectu
Indeed, and regarding to all the C books I've seen, a struct is a data type ;-)


~ Tectu

Re: Talking about naming conventions

Posted: Wed Oct 10, 2012 2:21 pm
by Giovanni
By types I mean something declared using the typedef keyword, a structure name is not a type under that definition.

Giovanni