Never defined structure

Viewed 1957

Is there any benefit in having never-defined structures in C ?

Example in SQLite source code :

/* struct sqlite3_stmt is never defined */
typedef struct sqlite3_stmt sqlite3_stmt;

And the object is manipulated like so :

typedef struct Vdbe Vdbe;
struct Vdbe {
    /* lots of members */
};


int sqlite3_step(sqlite3_stmt *pStmt) {
    Vdbe *v = (Vdbe*) pStmt;
    /* do stuff with v... */
}

So why not just use a usual abstract type, with the actual structure privately defined in foo.c source and a public typedef in foo.h header ?

2 Answers
Related