首页 > 系统相关 >linux第一宏

linux第一宏

时间:2024-08-19 13:55:27浏览次数:7  
标签:container struct 第一 list char linux foo type

ubuntu内下载源代码并找到宏源码

vim -t offsetof

987 #ifndef offsetof
 988 # define offsetof(typ, memb)     ((unsigned long)((char *)&(((typ *)0)->memb)))
 989 #endif

vim -t container_of

240 /**
241  * Returns a pointer to the container of this list element.
242  *
243  * Example:
244  * struct foo* f;
245  * f = container_of(&foo->entry, struct foo, entry);
246  * assert(f == foo);
247  *
248  * @param ptr Pointer to the struct list_head.
249  * @param type Data type of the list element.
250  * @param member Member name of the struct list_head field in the list element.
251  * @return A pointer to the data struct containing the list head.
252  */
253 #ifndef container_of
254 #define container_of(ptr, type, member) \
255     (type *)((char *)(ptr) - (char *) &((type *)0)->member)
256 #endif

确实巧妙

标签:container,struct,第一,list,char,linux,foo,type
From: https://www.cnblogs.com/aker-whale/p/18367159

相关文章

  • Linux下的库(静态与动态)原理与制作
    程序的编译过程程序的编译过程是将源代码转换为可执行文件的一系列步骤。这个过程通常包括预处理、编译、汇编和链接等阶段 1.预处理(Preprocessing)预处理器(cpp)处理源代码文件中的预处理指令,如#include和#define。它展开宏定义,包含头文件,并删除注释。输出是经过预处理的......
  • Java轻松实现跨平台(Windows、Linux)多协议(Twain、Sane)的Web扫描
     由于项目需要,开发在Windows下与Linux下扫描功能,Linux主要是信创的两个系统(UOS、麒麟),研究了一下发现,Windows使用Twain协议与扫描仪通讯,Linux使用的是Sane协议与扫描仪通讯,找到Twain协议和Sane协议的标准文档,英文的,都有大几百页,项目一个月内要求上线,明显没时间慢慢研究,于......
  • linux 安装python
    1、先查看系统python所在位置[root@localhost~]#whereispythonpython:/usr/bin/python/usr/bin/python2.7/usr/lib/python2.7/usr/lib64/python2.7/etc/python/usr/include/python2.7可确认系统原python环境在/usr/bin/下。2、进入/usr/bin/cd/usr/bin/3、先安......
  • 【~Linux系统性能调优技巧~】
    ......
  • 【Linux入门】DHCP与FTP原理及其配置实例
    文章目录DHCP原理一、DHCP概述二、DHCP的工作原理三、DHCP的分配方式四、DHCP的租约五、DHCP的应用场景FTP原理一、FTP概述二、FTP的工作原理三、FTP的连接模式四、FTP的应用配置实例DHCP配置实例DHCP服务器配置(CentOS7)1.环境准备2.安装DHCP服务3.配置网络接口4.......
  • Linux安装nginx1.26.2
    第一步:去官网下载指定的版本http://nginx.org/en/download.html第二步:解压压缩包:tar-zxvf  ......tar.gz第三步:编译nginx ./configure如果出现报错:./configure:error:theHTTPgzipmodulerequiresthezliblibrary.Youcaneitherdisablethemodulebyusing--......
  • Linux C++ 开发4 - 入门makefile一篇文章就够了
    1.make和Makefile1.1.什么是make?1.2.什么是Makefile?1.3.make与Makefile的关系2.Makefile的语法2.1.基本语法2.2.变量2.3.伪目标2.4.模式规则2.5.自动变量2.6.条件判断3.示例演示3.1.编译HelloWorld程序3.2.编译多文件项目3.2.1.项目......
  • python subprocess 执行Linux指令
    一、subprocess模块1、概述subprocess模块首先推荐使用的是它的run方法subprocess.run(),更高级的用法可以直接使用Popen接口subprocess.Popen()。2、优点安全性:与os.system相比,subprocess避免了shell注入攻击的风险。灵活性:subprocess可以与子进程的stdin、stdout和std......
  • 在前面定义的 Person 类中添加两个构造器: 第一个无参构造器:利用构造器设置所有人的 ag
    1publicclassConstructorExercise{2//编写一个main方法3publicstaticvoidmain(String[]args){4Personp1=newPerson();//无参构造器5//下面输出name=null,age=186System.out.println("p1的信息name="+p......
  • JetBrains DataSpell 2024.2 (macOS, Linux, Windows) - 专业数据科学家的 IDE
    JetBrainsDataSpell2024.2(macOS,Linux,Windows)-专业数据科学家的IDEJetBrains跨平台开发者工具请访问原文链接:https://sysin.org/blog/jetbrains-dataspell/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.orgJetBrainsDataSpell-专业数据科学家的IDE......