Useless variable name in C struct type definition

Posted by user1210233 on Stack Overflow See other posts from Stack Overflow or by user1210233
Published on 2012-12-06T22:56:22Z Indexed on 2012/12/06 23:03 UTC
Read the original article Hit count: 189

Filed under:
|
|

I'm implementing a linked list in C. Here's a struct that I made, which represents the linked list:

typedef struct llist {
  struct lnode* head; /* Head pointer either points to a node with data or NULL */
  struct lnode* tail; /* Tail pointer either points to a node with data or NULL */
  unsigned int size; /* Size of the linked list */
} list;

Isn't the "llist" basically useless. When a client uses this library and makes a new linked list, he would have the following declaration:

list myList;

So typing llist just before the opening brace is practically useless, right? The following code basically does the same job:

typedef struct {
  struct lnode* head; /* Head pointer either points to a node with data or NULL */
  struct lnode* tail; /* Tail pointer either points to a node with data or NULL */
  unsigned int size; /* Size of the linked list */
} list;

© Stack Overflow or respective owner

Related posts about c

    Related posts about struct