Such as:
typedef struct _cairo_clip cairo_clip_t;
Why not directly use _cairo_clip
? See numerous similar definitions in some code.
Such as:
typedef struct _cairo_clip cairo_clip_t;
Why not directly use _cairo_clip
? See numerous similar definitions in some code.
The idea behind typedef
is to let you skip the struct
keyword. Unlike C++, C does not let you do this:
struct _cairo_clip {
int a;
float b;
};
_cairo_clip cc; // Not allowed
struct _cairo_clip cc; // Allowed, but requires a keyword
If you tried to directly use _cairo_clip
, you would need to call it struct _cairo_clip
.
struct _cairo_clip
is more verbose than cairo_clip_t
.
Using a typedef also provides some abstraction, because it means that cairo_clip_t
can be implemented as either a built-in type or as implemented as a struct
, without causing a change in the syntax of the client code.