Reputation: 39881
Please tell me what is the difference of
typedef struct Tcl_ObjType {
char *name;
Tcl_FreeInternalRepProc *freeIntRepProc;
Tcl_DupInternalRepProc *dupIntRepProc;
Tcl_UpdateStringProc *updateStringProc;
Tcl_SetFromAnyProc *setFromAnyProc;
} Tcl_ObjType;
and
struct Tcl_ObjType {
char *name;
Tcl_FreeInternalRepProc *freeIntRepProc;
Tcl_DupInternalRepProc *dupIntRepProc;
Tcl_UpdateStringProc *updateStringProc;
Tcl_SetFromAnyProc *setFromAnyProc;
};
I have see the first version here: http://www.tcl.tk/man/tcl8.5/TclLib/ObjectType.htm , and don't know why it is written as it is.
Upvotes: 4
Views: 144
Reputation: 70718
You've gave the structure a type definition (In layman terms, provided an alternate name to an existing type):
Using your first example, you can then use it to reference objects/declare new objects via:
Tcl_ObjType newObj;
Upvotes: 1
Reputation: 258548
For C++, there is no difference.
If this was a C program and you used the first variant, you could do:
Tcl_ObjType instanceOfStructure;
instead of
struct Tcl_ObjType instanceOfStructure;
Upvotes: 9