Having just seen What does the following macro do? I gotta ask my own question: why do so many applications' headers define offsetof
themselves? Is there some reason why <stddef.h>
is not to be relied upon?
我不认为他们不信任标准offsetof
-至少从我所看到的来看,通常他们只是不知道它。
Is there some reason why is not to be relied upon?
I know one of the reasons. GCC produces a warning when standard offsetof() is used on fields of C++ classes. That leads some people to roll out their own version which doesn't trigger the warning.
又或者它是来自C编译器的不符合ANSI且没有offsetof
的旧代码?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.