标准typedef'ing [英] Standard for typedef'ing

查看:94
本文介绍了标准typedef'ing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GCC 4.4.4 C89

gcc 4.4.4 c89

我只是想知道是否有应该创建类型时遵循的标准。

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

例如:

typedef struct date
{
} date_t;

我也看到有人把资本是这样的:

I have also seen people put a capital like this:

typedef struct date
{
} Date;

或者变量

typedef unsigned int Age;

或本

typedef unsigned int age_t;

是否有应遵循任何标准。我个人preFER后用_t固定。

Is there any standard that should be followed. Personally I prefer post fixing with a _t.

非常感谢您的任何建议,

Many thanks for any suggestions,

推荐答案

这在很大程度上归结为个人的preference,关键是要一致(或者,如果你有一个公司约定,使用该)。下面的文章有一些命名指南:

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:

<一个href=\"http://www.montefiore.ulg.ac.be/~piater/Cours/Coding-Style/\">http://www.montefiore.ulg.ac.be/~piater/Cours/Coding-Style/

请注意,它切换'_t'部分:

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:

<一个href=\"http://stackoverflow.com/questions/1722112/what-are-the-most-common-naming-conventions-in-c\">http://stackoverflow.com/questions/1722112/what-are-the-most-common-naming-conventions-in-c

这篇关于标准typedef'ing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆