c语言奇淫技巧
简简单单的robert
底层开发工程师
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
c语言中offset和container_of宏的讲解
1.offset宏的讲解 # define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 1)((type *) 0) =》0地址强制转化为type类型的指针; 2) ((type *)0)->MEMBER =》 访问type结构中的MEMBER数据成员 3) &(((type *)0)->MEMBER) =》去除type结构中数据成员member的地址 4) (size_t)(&(((type *原创 2020-11-25 14:41:13 · 980 阅读 · 0 评论 -
c语言位数组(基于linux内核代码引发的思考)
首先来看一下linux内核代码,如下: #define BIT_PER_LONG (CHAR_BIT * sizeof(unsigned long)) #define BIT_MASK(idx) (1UL << ((idx) % BIT_PER_LONG)) #define BIT_WORD(idx) ((idx) / BIT_PER_LONG) /* Helpers */ static inline void __set_bit(unsigned idx, unsigned long *bm原创 2020-11-24 20:17:19 · 475 阅读 · 0 评论 -
c中形参修改值问题(指针传递和值传递)
首先,写代码的时候,写出类似如下的代码,最后出现了段错误: #define SIZE 10 void EncryptUpdata(int *ctx) { ctx = (int *)malloc(sizeof(int) * SIZE); return; } int main() { int *ctx = NULL; EncryptUpdata(ctx); UseCTX(ctx); return 0; } 写出这样的代码,主要是对函数参数传递的本质没有很深的了解。最关键的一点就是,永远要记住,形原创 2020-11-11 16:34:21 · 1651 阅读 · 0 评论
分享