Standard for typedef'ing

前端 未结 7 2066
清酒与你
清酒与你 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:02

    In general most languages allow the use of SentenceCase for non-standardized classes or types. I find this is the best practise, and in languages that allow it, additionally use namespaces or modules to prevent clashes. In languages that don't (such as C), a prefix where necessary never goes astray. To use a multi-language example for something I'm currently working on:

    C: typedef uint32_t CpfsMode;
    C++: namespace Cpfs { typedef uint32_t Mode; }
    Python: cpfs.Mode = int
    

提交回复
热议问题