Is t_whatever a reserved name in the C standard or POSIX? -


as far know:

an underscore (‘_’) , identifiers regardless of use begin either 2 underscores or underscore followed capital letter reserved names

in posix: names end ‘_t’ reserved additional type names.

in addition: header file sys/stat.h reserves names prefixed ‘st_’ , ‘s_’.

can use "t_whatever" (e.g. t_node) define our own types?

yes, can use t_ prefix, that's not in reserved space.

personally wouldn't recommend doing so, that's because i'm not convinced having prefix make type name more type name win, in many cases.

i can't see that

t_node head; 

is better than

node head; 

in fact, think latter more readable. it's case see usage if word type or variable name in c, in opinion.

one objection might can unclear when using sizeof, instance consider dynamically allocating new node. many people write as:

t_node *head = malloc(sizeof(t_node)); 

but i'm set against usage; consider better avoid handing type names sizeof whenever possible, , use variable instead, "locking" size destination type thing:

node *head = malloc(sizeof *head); 

also, usual, note never write first example that, since think makes sizeof function. have space:

t_node *head = malloc(sizeof (t_node)); 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -