开发者

Generic Bit Macros

开发者 https://www.devze.com 2023-02-07 07:24 出处:网络
I\'m looking for generic bit macros (e.g. extracting or setting multiple bits), so that I don\'t have to reinvent them. On NetBSD I found at least 开发者_运维知识库__BIT and __BITS in <sys/cdefs.h&

I'm looking for generic bit macros (e.g. extracting or setting multiple bits), so that I don't have to reinvent them. On NetBSD I found at least 开发者_运维知识库__BIT and __BITS in <sys/cdefs.h>, but glibc doesn't seem to have such macros (though GCC provides some more complex built-in bit functions). I haven't looked into other platforms yet. Does anyone know other predefined bit macros or functions?


I think there're none on MS (except the trivial HIWORD/LOWORD, etc) but on the other hand, why not use bit fields instead? If you have to deal with bits having a predefined layout, that is.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号