C/C++里面的struct和typedef
今天看到这样的代码
typedef struct _Abc {
uint64_t unit_id;
......
} Abc;
开始不理解这个的意思,后来看到这个解释:
https://stackoverflow.com/questions/5558994/naming-convention-when-using-struct-in-c
There is no benefit in user code, it's just ugly. In the second example, the HuffCode_ isn't even necessary since the struct type is already named by the typedef. The only places where this can be useful are: 1. When StructName is already in use, StructName_ gives a different name (but you should really come up with a better name).
2. Identifiers in the C standard library that are not defined by the standard shouldn't conflict with user code identifiers. Therefore, C library writers use the _ prefix in the hopes that users will not use that. Unfortunately, some users do.
3. In very old compilers, it may be useful to give the struct a different name than is used in the typedef. You need both the typedef and the other name if you're building a linked structure (example).
C/C++里面的struct和typedef的更多相关文章
- [转载]彻底弄清struct和typedef struct
struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...
- struct和typedef struct彻底明白了
struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...
- struct和typedef struct
转自:http://www.cnblogs.com/qyaizs/articles/2039101.html struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++ ...
- 学习hash_map从而了解如何写stl里面的hash函数和equal或者compare函数
---恢复内容开始--- 看到同事用unordered_map了所以找个帖子学习学习 http://blog.sina.com.cn/s/blog_4c98b9600100audq.html (一)为 ...
- 细说 struct和typedef struct
细说 struct和typedef struct 参考原文:http://www.cnblogs.com/qyaizs/articles/2039101.html,有些小改动~ 1 首先://注意在C ...
- C++/C中的struct和typedef struct用法和区别
struct和typedef struct 分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int ...
- 方阵里面的dp
打了一场luogu的信心赛,惊讶地发现我不会T2,感觉像这样在矩阵里面的dp看起来很套路的样子,但是仔细想想还是有很多需要注意的细节. 又想到之前貌似也考过一些类似的题目 然而我并没有改 ,于是打算补 ...
- Unity3D研究之Prefab里面的Prefab关联问题
Unity研究院之Prefab和GameObject的正向和逆向查找引用 我发现很多美工兄弟都爱问程序Unity3d为什么总丢材质? 我不排除U3d有BUG的情况下会丢材质?但是其实很多时候是人为操作 ...
- 关于c语言struct和typedef
C++中使用: struct test{ int x, y;};就可以定义一个名为 test的结构体,但C中很可能编译通不过.C语言并不支持在struct后使用标示符定义结构体的名字,test将 ...
随机推荐
- 优动漫PAINT-牵牛花画法教程
喇叭型对画者自身的塑形功力会有较高的要求,作者很靠谱的把他的塑形方式详细呈现了出来~ 对于这样的一个仿真效果的牵牛花完全可以使用优动漫PAINT完成,简单又快捷,软件下载:http://www.don ...
- How Javascript works (Javascript工作原理) (七) WebAssembly 对比 JavaScript 及其使用场景
个人总结: 1.webworkers实现了用多线程浏览器来进行多线程操作js的能力. 2.web workers不能操作dom,window,document等对象,一般用于cpu计算型的任务. ...
- BZOJ 4472 [Jsoi2015]salesman(树形DP)
4472: [Jsoi2015]salesman Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 417 Solved: 192[Submit][St ...
- 浅谈 MySQL的外键的作用
MySQL中外键的介绍: MySQL外键必须使用存储引擎为 innDB 其中MySAM 和MEMORYH这两种引擎不支持 由数据库自身保证数据一致性,完整性,更可靠,因为程序很难100%保证数据的 ...
- c进程学习日志
#include<unistd.h> #include<sys/types.h> #include<pwd.h> #include<stdio.h> i ...
- salt 安装kubernetes集群3节点
[root@linux-node1 k8s]# tree .├── etcd.sls├── files│ ├── cfssl-1.2│ │ ├── cfssl-certinfo_linux ...
- 题解 P3128 【[USACO15DEC]最大流Max Flow】
此类型题目有两种比较常见的做法:树链剖分和树上差分. 本题有多组修改一组询问,因此树上差分会比树链剖分优秀很多. 这里两种方法都进行介绍. 树链剖分和树上差分的本质都是将一颗树转换为一个区间,然后进行 ...
- How to customize Skin Gallery - Remove / rename skins and groups
1. REMOVE (HIDE) A SPECIFIC SKIN Traverse through the gallery group collection, then through its gal ...
- spfile
1 让ORACLE自己主动从spfile启动 SQL> create spfile='/dev/vx/rdsk/vgora/lv_spfile' from pfile; SQL> sh ...
- hdu_1754,线段树单点更新,求区间最值
http://www.notonlysuccess.com/index.php/segment-tree-complete/ #include<iostream> #include< ...