c - What is the advantage of specifying two types when creating a typedef'd struct? -
c - What is the advantage of specifying two types when creating a typedef'd struct? -
example 1:
struct t{ int a; }; creates type struct t
example 2:
typedef struct { int a; } t; creates type t
example 3:
typedef struct t{ int a; } t; creates both types struct t , t
i tend see illustration 3 lot, , i'm not sure why take on illustration 1 or 2.
are there advantages gain doing way? are there reasons people compatibility? is advantageous kind of scoping reason?i avoid doing example 3 way, because less maintenance on type, , restricts multiple ways of declaring same thing. however, reconsider it, if there benefits "double naming" technique.
i tend see illustration 3 lot, , i'm not sure why take on illustration 1 or 2.
are there advantages gain doing way?i hold truth self-evident, namely cumbersome code cumbersome. prefer write
t object; instead of
struct t object; however, hard-core c coder might think hey, t struct, improve phone call that , also, mitigates chance confusion you'd when doing
struct {int a; } t; typedef int t; are there reasons people compatibility? yes. way, structs in c can used used in c++.
is advantageous kind of scoping reason?no, not i'd aware of.
c struct coding-style typedef c11
Comments
Post a Comment