ChinaUnix.net
相关文章推荐:

containerofptr type member

标题中代码存于以下代码中,第二行中的typeof( ((type *)0)->member ) 为何这样写?typeof(member)不行么? #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) offsetof宏定义在[include/linux/stddef.h]中: #define offsetof(type, member) ((size_t) &((type *)0)->member)

by duanchitian - C/C++ - 2009-01-01 14:34:12 阅读(3239) 回复(2)

相关讨论

内核源码中形如:(type*)0->member 是什么含义??:shock: type:结构体类型 member:结构体的成员

by shaohui973 - 内核源码 - 2011-02-21 12:54:40 阅读(13564) 回复(22)

#include #include struct cona_t{ int i; int j; int v; char t[10]; unsigned short xy; }; struct cona_t ct; unsigned short xy; int main(int argc,char * argv[]) { int xy,z,addr1,addr2; struct cona_t * p; memset(&ct,0,sizeof(struct cona_t)); ct.i = ct.j = ct.v = 10; sprintf(ct.t,"%s","sdf"); ct.xy = 20; xy = &(((struct cona_t *)0)->j); z = &((&ct)-...

by hardie - Linux文档专区 - 2008-12-12 14:10:37 阅读(625) 回复(0)

浅析container_of(ptr, type, member) 文章来源:http://gliethttp.cublog.cn #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) #define offsetof(type, member) ((size_t) &((type *)0)->member) 1.ptr为物理地址,其类型和member类型一致,最终使用typeof( ((type *)0)->member ) 由编...

by gliethttp - Linux文档专区 - 2007-10-18 10:46:59 阅读(465) 回复(0)

#define offsetof(type, member) ((int)&(type *)0)->member) offsetof(struct sockaddr_in,sin_addr.s_addr) 取 sockaddr_in结构体内 sin_addr.s_addr 成员在结构体中的 便宜 ((int)&(struct sockaddr_in *)0) -> sin_addr.sin_addr 怎么理解的?

by Fatihyang - C/C++ - 2011-08-12 20:03:10 阅读(3055) 回复(4)

#include class ItemInfIter { public: virtual const char* gmnCndFile() = 0; private: ItemInfIter( const ItemInfIter& ); ItemInfIter operator=( const ItemInfIter& ); }; main() { printf("sfsd\n"); } -------------------------------- 编译的时候出错 a.c:9: error: invalid abstract return type for member function 'ItemInfIter ItemInfIter::o...

by windyloft - C/C++ - 2005-12-23 15:39:57 阅读(2643) 回复(3)

使用fork创建进程 pid_t fork(void); 例: #include #include #include #include #include int main() { pid_t pid; pid=fork(); if(pid==(pid_t)(-1)) { fprintf(stderr,"Fork:%s\n",strerror(errno)); exit(13); }else if(pid==0) { printf("PID:%ld:Child started ,parent is :%ld\n",(long)getpid(),(long)getppid())); }else { printf("PID:%ld:Started child PID:%ld\n",(long)getpid(),(long)pid); } sleep(1); return ...

by creatory - Linux文档专区 - 2008-03-31 20:27:17 阅读(483) 回复(0)

如题,想要筛选和统计一个source file 里面的member和相应的描述信息.

by liaojufeng2008 - AS400 - 2013-08-29 12:06:31 阅读(9583) 回复(2)

怎么用WRKDBF 来看一个PF里面的 member? 我对这方面的知识不太了解。 谢谢

by JustinCaribe - AS400 - 2008-12-01 12:37:08 阅读(1945) 回复(2)

1.STRQSH 2./usr/bin/find /qsys.lib/liba.lib -name 'pp*pp.mbr' :em49:

by neo2718 - AS400 - 2002-12-09 11:44:27 阅读(5861) 回复(19)

typedef void (SafeArray::*MFPTR1)(int, int); typedef int (SafeArray::*MFPTR2)(int); MFPTR1 mfPtr1 = 0; MFPTR2 mfPtr2 = 0; mfPtr1 = &SafeArray::set; mfPtr2 = &SafeArray::get; 为什么成员函数指针 需要使用 & 取地址? 而一般函数指针 不需要用到 & ? 谢谢

by shihyu - C/C++ - 2011-12-03 11:56:51 阅读(1951) 回复(2)