Standard for typedef'ing

前端 未结 7 1996
清酒与你
清酒与你 2020-12-30 02:41

gcc 4.4.4 c89

I am just wondering is there any standard that should be followed when creating types.

for example:

typedef struct date
{
} dat         


        
相关标签:
7条回答
  • 2020-12-30 03:22

    Much of this comes down to personal preference, with the key being to be consistent (or if you have a company convention, use that). The following article has some naming guides:

    http://www.montefiore.ulg.ac.be/~piater/Cours/Coding-Style/

    Note that it switches the '_t' portion:

    typedef struct node_t {
      void *content;
      struct node_t *next;
    } Node;
    
    typedef enum season_t { SPRING, SUMMER, FALL, WINTER } Season;
    

    There was an earlier discussion on C naming conventions here:

    What are the most common naming conventions in C?

    0 讨论(0)
提交回复
热议问题