Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大哥,能不能帮我解释你下面这个宏? #24

Open
panyaorong opened this issue Aug 4, 2020 · 1 comment
Open

大哥,能不能帮我解释你下面这个宏? #24

panyaorong opened this issue Aug 4, 2020 · 1 comment

Comments

@panyaorong
Copy link

#define HandlerFromOverlaped(ptr) ((ExtendHandle*)((char*)ptr - (char*)&((ExtendHandle*)NULL)->_overlapped))
我不明白,这个((ExtendHandle*)NULL)->_overlapped,这个不会有问题么?

@R32
Copy link

R32 commented Sep 28, 2020

你说的这个 ((ExtendHandle*)NULL)->_overlapped 其实就是 offset() 宏所做的 (msvc/gcc 都有),
而这整个意思估计就是 container_of() 宏, 在 gcc 中 container_of() 有更安全的写法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants