Talking about naming conventions

Locked
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Talking about naming conventions

Post 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
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Talking about naming conventions

Post by Tectu »

Over IRC, mobyfab and barthess both told me that they both prefer the _t suffix.


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Talking about naming conventions

Post by Giovanni »

Usually _t is for types in general not structures.

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Talking about naming conventions

Post by Tectu »

Indeed, and regarding to all the C books I've seen, a struct is a data type ;-)


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Talking about naming conventions

Post by Giovanni »

By types I mean something declared using the typedef keyword, a structure name is not a type under that definition.

Giovanni
Locked