简体   繁体   English

以下片段的区别

[英]Difference of the following snippets

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. 我在这里看到第一个版本: http//www.tcl.tk/man/tcl8.5/TclLib/ObjectType.htm ,并且不知道为什么它按原样写入。

For C++ , there is no difference. 对于C ++ ,没有区别。

If this was a C program and you used the first variant, you could do: 如果这是一个C程序并且你使用了第一个变体,你可以这样做:

Tcl_ObjType instanceOfStructure;

instead of 代替

struct Tcl_ObjType instanceOfStructure;

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM